[RFC] Change cleanupOutputBeforeBuild() to use beforeEmit:true for later deleting
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.
Not sure if that's still an issue but the person that added this option recommended not to use it in dev here: https://github.com/johnagan/clean-webpack-plugin/issues/67#issuecomment-407654849
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
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 :).
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.
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!