Does not wait for process to finish
We have a process that writes a value to a file which is then required by the actual build process like this:
git describe --tags HEAD >.app-version || date --rfc-3339=seconds >.app-version
Then, the "version file" generated as above is require()d in the application source.
It turns out this plugin does not wait for the command to finish before passing control back to webpack, because today we got an error during the JS build:
ModuleNotFoundError: Module not found: Error: Cannot resolve 'file' or 'directory' ../.app-version in /builds/xxx/src
Here is a more minimal demonstration:
new WebpackShellPlugin({
onBuildStart: [
'sleep 60; touch .myfile'
],
safe: true
})
Then, if you run your build as usual, it will actually finish before the file has been created. This prevents you from require()ing files generated as such in your webpack project.
I see 2 solutions:
- Use the callback interface provided by Webpack plugin API, or
- Use execSync instead of exec
Same issue here,plugin should wait for process to finish if possible. It's causing a compile loop for me because the pre-build process emits input for the actual webpack compilation after webpack has already completed its build process.
Just made a pr https://github.com/1337programming/webpack-shell-plugin/pull/50
It would be great to get this merged - this is a pretty big blocker for using this lib for us.
Is there any update on merging the PR? I can use npm pre- hook for now, but it doesn't execute when webpack rebuild the project on watch. This is a great plugin, it would be perfect for me if this feature is implemented. thanks!
Having the compile loop issue here too. would love to see this being merged!
I made a fork that allows you to block until the scripts finish execution. please check it out: https://www.npmjs.com/package/webpack-synchronizable-shell-plugin