將index.html文件放在src文件夾中
在webpack.config.js中配置:
1.const htmlPlugin = require('html-webpack-plugin');
2./*需要npm install --save-dev html-webpack-plugin*/
3.
plugins:[
new htmlPlugin({
minify:{
removeAttributeQuotes:true
},
hash:true,/*防止緩存*/
template:'./src/index.html'
})
],
配置完成後,執行webpack,會自動生成dist文件(包括出口文件和index.html)