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

Conflict with CleanWebpackPlugin #58

Closed
my-lalex opened this issue Sep 2, 2022 · 7 comments · Fixed by #59
Closed

Conflict with CleanWebpackPlugin #58

my-lalex opened this issue Sep 2, 2022 · 7 comments · Fixed by #59

Comments

@my-lalex
Copy link

my-lalex commented Sep 2, 2022

It seems that CleanWebpackPlugin is removing files generated by this plugin...

I'm currently investigating a bit to find out if the plugin is emitting files too soon, or CleanWebpackPlugin is removing files too late... I don't have much time to spend on this, so it could take a bit of time for me to find out.

If anyone already knows the plugin quite well and the answer, please let me know ;-)

@mcollina
Copy link
Member

mcollina commented Sep 2, 2022

Unfortunately no :(.

@simoneb
Copy link
Collaborator

simoneb commented Sep 2, 2022

/cc @ShogunPanda

@my-lalex
Copy link
Author

my-lalex commented Sep 2, 2022

It seems like CleanWebpackPlugin is using the compiler done hook, and the assets from its stats parameter.

By adding a log in the hook, I see that only the 'main.js' file is in the assets, none of the "pino files" are part of it...
I don't know how to add child compilers assets to the main one, still investigating...

@my-lalex
Copy link
Author

my-lalex commented Sep 2, 2022

I found a ggod article about childCompiler: https://medium.com/@prateekbh/my-experience-writing-a-webpacks-child-compiler-plugin-a1237c175947

Step 5: Tell parent compiler about errors, assets and named chunks

So even if you don’t do this it might work fine with you as the files are generated and you are free to use them. However if any other plugin(say HtmlWebpackPlugin) is trying to know the output, your additional assets will not be visible to it. In a nutshell you have to tell the parent compiler about the assets and named chunks you generated

compilation.assets = Object.assign(childCompilation.assets, compilation.assets);
Please use the additionalAssets hook of the parent compilation to make sure you dont end up in a race condition with other plugin.

I'm still a bit confused about where to put the additionalAssets hook, but seem to be the good direction 😅

@my-lalex
Copy link
Author

my-lalex commented Sep 2, 2022

OK. I got the solution running, but I never made a PR 😅
I'm currently learning how to and send it

@lalexdotcom
Copy link
Contributor

Made it (this is my personal account) 😎 #59

(my first PR, I'm so proud)

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

Successfully merging a pull request may close this issue.

4 participants