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

Does the order of clean-webpack-plugin matter? #200

Open
intrepid-ishan opened this issue Apr 26, 2021 · 2 comments
Open

Does the order of clean-webpack-plugin matter? #200

intrepid-ishan opened this issue Apr 26, 2021 · 2 comments

Comments

@intrepid-ishan
Copy link

Does the order of CleanWebpackPlugin matter?

In my project, I am running plugins in the below order, as you can see CleanWebpackPlugin is the last item in the array. Will that impact my build?

plugins: [
  new MomentLocalesPlugin(), 
  new webpack.DefinePlugin(),
  new HtmlWebpackPlugin(),
  new CopyWebpackPlugin(),
  new CleanWebpackPlugin()
]
@ankurk91
Copy link

No, it does not

@axibyte
Copy link

axibyte commented Dec 30, 2021

In my case the order was important and CleanWebpackPlugin should always be the first plugin to declare.

Here is the issue: the CleanWebpackPlugin uses the emit hook to perform the initial clean stage. If any other plugin uses the same hook "emit" to write files to the output directory, the file will be deleted if the handler of the emit event of this particular plugin was called first.

Example of such plugin is the "Chunks2JsonPlugin".

Placing the Chunks2JsonPlugin before the CleanWebpackPlugin will remove the file generated by the Chunks2JsonPlugin

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

No branches or pull requests

3 participants