官方文档中关于清理程序的示例
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
+ const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
print: './src/print.js'
},
plugins: [
+ new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
title: 'Output Management'
})
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
打包时会报错clean-webpack-plugin only accepts an options object
改为
new CleanWebpackPlugin(),问题解决,github上的https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional 介绍了用法