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

[RFC] Change cleanupOutputBeforeBuild() to use beforeEmit:true for later deleting #469

Open
weaverryan opened this issue Dec 5, 2018 · 4 comments

Comments

@weaverryan
Copy link
Member

The https://github.com/johnagan/clean-webpack-plugin has a beforeEmit option that default to false. When this is true, it deletes the files later - right before emit. This means that the time between when the files are deleted and recreated is much smaller.

I think we should change this to be the default behavior. For some deploys, deleting the old files at the beginning means that their production site is missing the files until the build finishes. Probably those deploy systems could be made better - but beforeEmit also seems like a better way to do things in general.

@Lyrkan
Copy link
Collaborator

Lyrkan commented Dec 5, 2018

Not sure if that's still an issue but the person that added this option recommended not to use it in dev here: johnagan/clean-webpack-plugin#67 (comment)

@nsaleh
Copy link

nsaleh commented Dec 15, 2018

Hey Ryan,

guy from symfonycon here :),
I found some time now and started looking into this, still digging into it though...

I just tried setting beforeEmit in webpack.config.js:

.cleanupOutputBeforeBuild(['**/*'], options => { options.beforeEmit = true; })

It's working as i'd expect it in dev and production (no more "missing manifest.json"), but it's a very minimalistic project. I'll make some more tests soon and maybe give my "swap" approach a shot.

If it is a problem in dev context one might use Encore.isProduction() to just use it there. However it would be nice in dev too I guess.

Nabil

@weaverryan
Copy link
Member Author

Hey Nabil! Thanks for checking it out! Make sure to also try dev-server - there was some indication that there may be a problem with that, but the details were vague.

Thanks for following up on this :).

@adrian-delgado
Copy link

adrian-delgado commented Oct 22, 2019

For some deploys, deleting the old files at the beginning means that their production site is missing the files until the build finishes.

On a similar note, if the build fails, the output folder will also be cleaned.

In the latest release of clean-webpack-plugin if the build fails, the output folder is not cleared.

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

4 participants