1.把dist中的index.html复制到src目录中,并去掉咱们引入的jsjavascript
2.在webpack.config.js中引入html
const htmlPlugin = require('html-webpack-plugin');
3.引入后进行安装 cnpm i html-webpack-plugin --save-dev前端
4.在webpack.config.js中进行插件配置java
new htmlPlugin({ minify:{ removeAttributeQuotes:true }, hash:true, template:'./src/index.html' })
5.在终端中输入webpack,进行打包,你会看到index.html文件已经被咱们打包到dist文件目录下了,而且自动引入了js文件webpack
上图:web
前端必学内容:webpack(模块打包器)npm
webpack3 学习内容,点击便可到达babel
若是个人内容对你有帮助,欢迎打赏模块化