johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 135 forks source link

Perform clean just before emiting files to output dir #72

Closed ChrisRAoW closed 6 years ago

ChrisRAoW commented 6 years ago

Currently the files are removed at the beginning of the compiliing process. For production environments that isn't really what you want, because:

So basically you want the old assets to be cleaned just before the new files are emitted to the output dir.

This PR does exactly that by using the event hook of the compiler named "emit".

The only thing you have to do is setting "beforeEmit" to true in the options.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-3.3%) to 87.156% when pulling 93cd388700323565b9f4ef03db219a088499241b on chrisschrijver:master into 01d8dda5f7df5966ce1c576a9e39998f9394527e on johnagan:master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-3.3%) to 87.156% when pulling a2f6a12fd5055acbbbd7e9d322a5a98b86599c96 on chrisschrijver:master into 01d8dda5f7df5966ce1c576a9e39998f9394527e on johnagan:master.

factoidforrest commented 6 years ago

I really, really like this option. I have noticed many times that things end up in a weird state when a build fails.

Obviously, it's not the right choice some of the time, but sometimes you really need it.

johnagan commented 6 years ago

awesome addition. thank you!

ChrisRAoW commented 6 years ago

You're welcome. Happy to contribute.