//安装
cnpm i html-webpack-plugin -D
//在src下新建一个模板index.html
//插件做的事情是在内存中创建一个index.html并引入打包后的js文件
//此时webpack.config.js变成如下
let path = require("path")
let hwp = require("html-webpack-plugin")
module.exports = {
//开发服务器的配置
devServer:{
port:3000,
progress:true,
contentBase:'./dabao'
},
mode:"development",
entry:"./src/index.js",
output:{
filename:"build.js",
path:path.resolve(__dirname,'dabao')
},
plugins:[
new hwp({
template:"./src/index.html"
})
]
}