webpack-shell-plugin-next icon indicating copy to clipboard operation
webpack-shell-plugin-next copied to clipboard

onBuildStart scripts runs multiple times

Open rm-arun-kumar opened this issue 3 months ago • 3 comments

Hi, I’m running some scripts with this plugin using the onBeforeBuild, onBuildStart, and onBuildEnd hooks on build process. I’ve noticed that the pre-build scripts execute multiple times regardless. I have recursive function inside node ./build/scripts/cleanupTemp.js task. If onBuildStart has more than one task, the issue occurs

My config:

plugins: [
            // Other configs
            new WebpackShellPluginNext({
                onBeforeBuild: {
                    scripts: [
                        'echo "NPM version => $(npm -v)"',
                        'echo "Node version => $(node -v)"'
                    ]
                },
                onBuildStart: {
                    scripts: [
                        'echo "Webpack Start"',
                        'node ./build/scripts/cleanupTemp.js'
                    ]
                },
                onBuildEnd: {
                    scripts: [
                        'echo "Webpack End"',
                        'node ./build/scripts/postBuild.js',
                        'node ./build/entryLoad.js',
                    ],
                    blocking: true
                }
            }),
   //  Other configs 

Log:

Image

Package version: Tested with 2.2.2 and the latest 2.3.3 → same issue.

I have tried with node v22.11.0 and v24.5.0 versions.!

rm-arun-kumar avatar Aug 21 '25 11:08 rm-arun-kumar

and onBeforeBuild scripts are not executing either

rm-arun-kumar avatar Aug 26 '25 06:08 rm-arun-kumar

@s00d Do I need to do change any config or something?. If yes please let me know.! (I'm using rspack for build compilation)

rm-arun-kumar avatar Aug 26 '25 06:08 rm-arun-kumar

Image

Hi, I have a test file in the project root to check how https://github.com/s00d/webpack-shell-plugin-next/blob/master/webpack.config.ts works. As you can see in the screenshot, there are no repeated runs. I can’t say for sure what the issue is on your side — I’ll need a test project where I can reproduce the problem.

s00d avatar Aug 26 '25 16:08 s00d