Options and Defaults (Optional)
new CleanWebpackPlugin({
// Simulate the removal of files
// 模拟删除文件
//
// default: false
dry: true,
// Write Logs to Console
// 将日志写入控制台
// (Always enabled when dry is true)
// 当dry 为真时始终启用
// default: false
verbose: true,
// Automatically remove all unused webpack assets on rebuild
// 重建时自动删除所有未使用的网页包资产
// default: true
cleanStaleWebpackAssets: false,
// Do not allow removal of current webpack assets
// 不允许删除当前的网页包资产
// default: true
protectWebpackAssets: false,
// **WARNING**
//
// Notes for the below options:
// 以下选项的注意事项:
// They are unsafe...so test initially with dry: true.
// 他们不安全。。。所以先用dry测试:true。
// Relative to webpack's output.path directory.
// 相对于webpack的输出。路径目录。
// If outside of webpack's output.path directory,
// 如果在webpack的输出之外。路径目录,
// use full path. path.join(process.cwd(), 'build/**/*')
//
// These options extend del's pattern matching API.
// 这些选项扩展了del的模式匹配API。
// See https://github.com/sindresorhus/del#patterns
// for pattern matching documentation
// 模式匹配文档
// Removes files once prior to Webpack compilation
// 在编译网页包之前删除一次文件
// Not included in rebuilds (watch mode)
// 不包括在重建中(观察模式)
// Use !negative patterns to exclude files
// 使用排除文件的负面模式
// default: ['**/*']
cleanOnceBeforeBuildPatterns: [
'**/*',
'!static-files*',
'!directoryToExclude/**',
],
cleanOnceBeforeBuildPatterns: [], // disables cleanOnceBeforeBuildPatterns
// Removes files after every build (including watch mode) that match this pattern.
// Used for files that are not created directly by Webpack.
//
// Use !negative patterns to exclude files
//
// default: []
cleanAfterEveryBuildPatterns: ['static*.*', '!static1.js'],
// Allow clean patterns outside of process.cwd()
//
// requires dry option to be explicitly set
//
// default: false
dangerouslyAllowCleanPatternsOutsideProject: true,
});