關于 clean-webpack-plugin3.x 的配置說明
// Simulate the removal of files
// 模擬刪除文件 僅僅報告要刪除的文件并不刪除
// default: false
dry: true,
// Write Logs to Console
// (Always enabled when dry is true)
// 報告刪除的文件
// default: false
verbose: true,
// Automatically remove all unused webpack assets on rebuild
// 重建的時候自動刪除 webpack 沒有使用的資源
// default: true
cleanStaleWebpackAssets: false,
// Do not allow removal of current webpack assets
// 不允許刪除cleanOnceBeforeBuildPatterns 中的文件
// default: true
protectWebpackAssets: false,
// **WARNING**
//
// Notes for the below options:
//
// They are unsafe...so test initially with dry: true.
//
// Relative to webpack's output.path directory.
// If outside of webpack's output.path directory,
// use full path. path.join(process.cwd(), 'build/**/*')
//
// These options extend del's pattern matching 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*'],
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