You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// es modulesimport{CleanWebpackPlugin}from'clean-webpack-plugin';// common jsconst{ CleanWebpackPlugin }=require('clean-webpack-plugin');
If using basic config new CleanWebpackPlugin(['dist']), simply remove ['dist'] and everything will work as expected. Otherwise read carefully below.
Defaults
All files inside webpack's output.path directory will be removed, but the directory itself will not be. If using webpack 4+'s default configuration, this means everything under <PROJECT_DIR>/dist/. Use cleanOnceBeforeBuildPatterns to override this behavior.
During rebuilds, all webpack assets that are not used anymore will be removed automatically.
Options:
cleanOnceBeforeBuildPatterns: Runs before webpack emits files to output.path. This happens once during the initial webpack build, but not rebuilds. Will run regardless of webpack errors.
cleanAfterEveryBuildPatterns: Runs after webpack has completed build. Happens after initial webpack build and after every subsequent successful rebuild. Will not run if any webpack errors are detected.
IMPORTANT: cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns patterns are relative to webpack's output.path. If outside output.path, use an absolute path path.join(process.cwd(), 'build/**/*') and run first with dry: true to ensure nothing unexpected is deleted.
cleanStaleWebpackAssets: Automatically remove unused webpack assets on rebuilds.
protectWebpackAssets: Do not allow custom pattern matching found in cleanAfterEveryBuildPatterns to remove current webpack assets.
dry: Only report files to be removed but do not actually delete any files.
verbose: Report files that were removed.
dangerouslyAllowCleanPatternsOutsideProject: Should only be used if removing files using cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns outside of process.cwd(). Be very careful with this option. You can permanently delete more than just your project files.
Outdated v1 options:
paths: Use cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns.
beforeEmit: Use cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns.
exclude: Use !negative pattern matching with cleanOnceBeforeBuildPatterns and/or cleanAfterEveryBuildPatterns.
watch: Not needed. Use cleanAfterEveryBuildPatterns to remove non-webpack files after rebuild.
allowExternal: Renamed to dangerouslyAllowCleanPatternsOutsideProject. You most likely do not need this option with version v2 because it checks against process.cwd() rather than plugin option root.
root: No longer used.
The text was updated successfully, but these errors were encountered:
chrisblossom
changed the title
v2 notes
Additional v2 Information - Please read before submitting new issues
Mar 5, 2019
chrisblossom
changed the title
Additional v2 Information - Please read before submitting new issues
Additional v2/v3 Information - Please read before submitting new issues
May 30, 2019
chrisblossom
changed the title
Additional v2/v3 Information - Please read before submitting new issues
Additional v2+ Information - Please read before submitting new issues
May 30, 2019
chrisblossom
changed the title
Additional v2+ Information - Please read before submitting new issues
Additional Upgrade Information - Please read before submitting new issues
May 30, 2019
You most likely do not need any configuration for this plugin to work as expected. Regardless, please take the time to read below.
Relavant:
output.path
process.cwd()
Migration
CleanWebpackPlugin
:new CleanWebpackPlugin(['dist'])
, simply remove['dist']
and everything will work as expected. Otherwise read carefully below.Defaults
All files inside webpack's
output.path
directory will be removed, but the directory itself will not be. If using webpack 4+'s default configuration, this means everything under<PROJECT_DIR>/dist/
. UsecleanOnceBeforeBuildPatterns
to override this behavior.During rebuilds, all webpack assets that are not used anymore will be removed automatically.
Options:
cleanOnceBeforeBuildPatterns
: Runs before webpack emits files tooutput.path
. This happens once during the initial webpack build, but not rebuilds. Will run regardless of webpack errors.cleanAfterEveryBuildPatterns
: Runs after webpack has completed build. Happens after initial webpack build and after every subsequent successful rebuild. Will not run if any webpack errors are detected.cleanStaleWebpackAssets
: Automatically remove unused webpack assets on rebuilds.protectWebpackAssets
: Do not allow custom pattern matching found incleanAfterEveryBuildPatterns
to remove current webpack assets.dry
: Only report files to be removed but do not actually delete any files.verbose
: Report files that were removed.dangerouslyAllowCleanPatternsOutsideProject
: Should only be used if removing files usingcleanOnceBeforeBuildPatterns
and/orcleanAfterEveryBuildPatterns
outside ofprocess.cwd()
. Be very careful with this option. You can permanently delete more than just your project files.Outdated
v1
options:paths
: UsecleanOnceBeforeBuildPatterns
and/orcleanAfterEveryBuildPatterns
.beforeEmit
: UsecleanOnceBeforeBuildPatterns
and/orcleanAfterEveryBuildPatterns
.exclude
: Use!negative
pattern matching withcleanOnceBeforeBuildPatterns
and/orcleanAfterEveryBuildPatterns
.watch
: Not needed. UsecleanAfterEveryBuildPatterns
to remove non-webpack files after rebuild.allowExternal
: Renamed todangerouslyAllowCleanPatternsOutsideProject
. You most likely do not need this option with versionv2
because it checks againstprocess.cwd()
rather than plugin optionroot
.root
: No longer used.The text was updated successfully, but these errors were encountered: