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
若是個人內容對你有幫助,歡迎打賞模塊化