安装
npm -d install html-webpack-plugin
引入
const htmlPlugin = require('html-webpack-plugin');
plugins: [
new htmlPlugin({
minify: {
removeAttributeQuotes: true, //去掉html属性引号
},
hash: true,
template: './src/index.html'
}),
]
新建 ./src/index.html什么都不引入
打包后发现:
1、index.html打包到./dist/index.html并且引入入口文件./dist/entry.js
2、./dist/index.html的属性没有双引号,并且script引入有hash值