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

V2 dist folder content is deleted before webpack start building #133

Closed
jimblue opened this issue May 2, 2019 · 8 comments
Closed

V2 dist folder content is deleted before webpack start building #133

jimblue opened this issue May 2, 2019 · 8 comments

Comments

@jimblue
Copy link

jimblue commented May 2, 2019

Issue description or question

Hi,

I've read the doc and a bunch of closed issue about this, but I didn't get how to replicate beforeEmit of V1?

Just need to stop removing all assets before webpack even start to bundle them...

Thank you so much for you help.

Cheers

Webpack Config

const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    plugins: [
        new CleanWebpackPlugin()
    ],
};

Environment

System:
    OS: macOS Mojave 10.14.4
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 14.43 GB / 32.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
    npm: 6.9.0 - ~/.nvm/versions/node/v10.15.1/bin/npm
@chrisblossom
Copy link
Collaborator

I must say I am confused about how beforeEmit worked previously. It is my understanding that the compile hook happens before the emit hook, so to me they are accomplishing the same thing, unless you are wanting to clean after the compile hook. In that case, you should be able to use cleanAfterEveryBuildPatterns.

I wouldn't be against the idea of adding a custom hook option, but I'd like to understand the use case for this first. Is it possible for you to provide a minimal example to show what issue you are running into?

@jimblue
Copy link
Author

jimblue commented May 2, 2019

Ok, let say my app is working well on production and I have new version of the app to build and push.
If I launch webpack build and it fails, the dist folder will be empty and my app will be broken.

To prevent that, clean-webpack-plugin should wait for build success before removing dist folder content.

That way the new build will replace the removed one and the app will never be broken in case the build add an error...

@chrisblossom
Copy link
Collaborator

Thanks for the explanation, it makes a lot of sense and we already do this for cleanAfterEveryBuildPatterns.

Any thoughts of why we wouldn't always use the emit hook over compile?

@chrisblossom
Copy link
Collaborator

@jimblue See #134

@jimblue
Copy link
Author

jimblue commented May 3, 2019

Nice!!!! That was fast... thank you

@rohit-gohri
Copy link

When can we expect a release for this?

@johnagan
Copy link
Owner

done https://www.npmjs.com/package/clean-webpack-plugin

@jimblue
Copy link
Author

jimblue commented May 31, 2019

Thanks @johnagan, it's working great now !

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