Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Upgrade Information - Please read before submitting new issues #106

Open
Tracked by #1301
chrisblossom opened this issue Mar 5, 2019 · 2 comments
Open
Tracked by #1301

Comments

@chrisblossom
Copy link
Collaborator

chrisblossom commented Mar 5, 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:

Migration

  • Use named export CleanWebpackPlugin:
// es modules
import { CleanWebpackPlugin } from 'clean-webpack-plugin';

// common js
const { 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.

@chrisblossom chrisblossom changed the title v2 notes Additional v2 Information - Please read before submitting new issues Mar 5, 2019
@chrisblossom chrisblossom pinned this issue Mar 5, 2019
Repository owner locked and limited conversation to collaborators Mar 5, 2019
Repository owner unlocked this conversation Mar 5, 2019
Repository owner locked and limited conversation to collaborators Mar 6, 2019
@johnagan
Copy link
Owner

@chrisblossom should we close/update?

@chrisblossom 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 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 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
@chrisblossom
Copy link
Collaborator Author

Updated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants