Files are removed every build in webpack watch mode even cleanAfterEveryBuildPatterns off
redplane opened this issue · comments
Issue description or question
Webpack Config
// List of directories to be cleaned.
// Absolute path to your webpack root folder (paths appended to this)
// Write logs to console.
verbose: true,
// Use boolean "true" to test/emulate delete. (will not remove files).
// Default: false - remove files
dry: false,
cleanOnceBeforeBuildPatterns: ['**\/*'],
protectWebpackAssets: true,
// allow the plugin to clean folders outside of the webpack root.
// Default: false - don't allow clean folder outside of the webpack root
dangerouslyAllowCleanPatternsOutsideProject: true
Environment
Run: npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 1.16 GB / 7.90 GB
Binaries:
Node: 10.13.0 - C:\Program Files\nodejs\node.EXE
npm: 6.10.0 - C:\Users\leoli\AppData\Roaming\npm\npm.CMD
Package.json
"webpack": "^4.35.2"
"clean-webpack-plugin": "^3.0.0"
Everytime when webpack rebuilt the application (because watch mode
has been enabled & files had changed), every files were removed.
Expectation:
Files are not removed.
It looks like this is the configuration you are looking for:
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
Thank you, it worked :)