我在title里设置了<title><%= HtmlWebpackPlugin.options.title %></title> 打包时提示HtmlWebpackPlugin未定义
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= HtmlWebpackPlugin.options.title %></title>
</head>
<body>
</body>
</html>
const path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin'); // 通过 npm 安装
const webpack = require('webpack'); // 用于访问内置插件
module.exports={
entry:"./src/script/main.js",
output:{
path:path.resolve(__dirname, 'dist'),
filename:"js/bundle.js"
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new HtmlWebpackPlugin({
//打包后的文件的名字
filename:'index1.html',
//以index为模板
template:"index.html",
//把打包后的js 引入到 头部还是尾部
inject:"body",
// 页面可以得到
title:"awebsdfsdfs",
date:new Date(),
})
]
}