webpack4——打包html文件

將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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章