1. 安装
cnpm install html-webpack-plugin --save-dev
2. webpack.config.js中使用
const htmlWebpackPlugin = require('html-webpack-plugin');
//插件配置 plugins: [ new htmlWebpackPlugin({ template: './src/index.html', //hash主要是清除缓存用 hash: true, //开发期间可以不用设置,主要是方便查看生成的文件 // minify:{ // removeAttributeQuotes:true,//去除引号 // collapseWhitespace:true, //html压缩为一行 // } }), ],