1.把dist中的index.html复制到src目录中,并去掉我们引入的js
2.在webpack.config.js中引入
const htmlPlugin = require(‘html-webpack-plugin‘);
3.引入后进行安装 cnpm i html-webpack-plugin --save-dev
4.在webpack.config.js中进行插件配置
new htmlPlugin({ ???minify:{ ???????removeAttributeQuotes:true ???}, ???hash:true, ???template:‘./src/index.html‘ })
5.在终端中输入webpack,进行打包,你会看到index.html文件已经被我们打包到dist文件目录下了,并且自动引入了js文件
上图:
webpack快速入门——插件配置:HTML文件的发布
原文地址:http://www.cnblogs.com/hezihao/p/7930287.html