HtmlPlugin插件里配置:
var htmlWebpackPlugin = require(‘html-webpack-plugin’);const CleanWebpackPlugin = require(‘clean-webpack-plugin’);let pathsToClean = [‘dist’,];module.exports = {entry: ‘./src/app.js’,output: {path: __dirname + ‘/dist’,filename: ‘main.[chunkhash].js’,},plugins: [new htmlWebpackPlugin({template: ‘./src/footer.html’,hash: true,filename: “footer.html”,minify: {collapseWhitespace: false}}),new CleanWebpackPlugin(pathsToClean),],module: {rules: [{test: /\.css$/,use: [‘style-loader’, ‘css-loader’]}]}};