s00d / webpack-shell-plugin-next

Run shell commands either before or after webpack 4 and 5 builds
MIT License
92 stars 12 forks source link

onAfterDone With multiple child configs #31

Open bcis-kassel opened 3 years ago

bcis-kassel commented 3 years ago

Hi, I have a webpack config with two child-configs (one for the frontend and one for the backend). In order to execute my onAfterDone-scripts in webpacks watch mode, I have to add the webpack-shell-plugin-next to both configs (frontend and backend). Otherwise, my script will only be executed on rebuild of the config that includes the webpack-shell-plugin-next. The problem with that solution is, that my script is executed twice, if both configuration are rebuilt.

I also tried to add a 3rd configuration that just contains the webpack-shell-plugin-next, but this configuration terminates immediately and executed the onAfterDone-script before the other configurations are finished.

So my question is: How do I have to setup webpack-shell-plugin-next to execute my script only once, while webpack rebuilds only some of the child configurations. Even if all child configurations are rebuilt, the runtime of them varies.

Thanks of the great plugin so far.

s00d commented 3 years ago

Hello. Create an example, it's so hard to understand.

Zomono commented 3 years ago

It is more a problem of webpack. Webpack does not provide afterALLDone hooks. Have a look at the workaround descriped in the answer of https://stackoverflow.com/questions/68496721/webpack-execute-task-after-all-configurations-are-done-or-before-all for an example.

It is all about returning an array (export default [{...}, {...}, [...}]) of webpack configugrations and the need to execute tasks after all configrations are done and not after a single configuration is done.

If you have an idea how to workaround this problem this would be very useful, otherwise this issue could be closed as it is more a problem with webpack.