{"id":20832,"library":"webpack-spawn-plugin","title":"webpack-spawn-plugin","description":"A webpack plugin that runs child_process.spawn during compilation, useful for running shell commands or starting processes as part of the build pipeline. The latest stable version is 0.3.0, released infrequently with last update in 2018. It supports Webpack 4+ hooks via the 'when' option (default 'done') and offers a 'persistent' flag to avoid respawning on recompilation. Compared to alternatives like webpack-shell-plugin or webpack-exec-plugin, this one directly uses Node's spawn for more control over stdio and process handling.","status":"maintenance","version":"0.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/diegohaz/webpack-spawn-plugin","tags":["javascript","webpack-spawn-plugin","webpack"],"install":[{"cmd":"npm install webpack-spawn-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-spawn-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-spawn-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a class; CommonJS require works but TypeScript may need esModuleInterop.","wrong":"const SpawnPlugin = require('webpack-spawn-plugin')","symbol":"default","correct":"import SpawnPlugin from 'webpack-spawn-plugin'"}],"quickstart":{"code":"import SpawnPlugin from 'webpack-spawn-plugin';\n\nexport default {\n  entry: './src/index.js',\n  output: { filename: 'bundle.js' },\n  plugins: [\n    new SpawnPlugin('node', ['-e', \"console.log('Hello from webpack-spawn-plugin!'); process.exit(0);\"], { persistent: false }),\n  ],\n};","lang":"typescript","description":"Shows basic usage: import the plugin, create a new instance with command and arguments, and add to plugins array."},"warnings":[{"fix":"Use webpack 4+ or stick with v0.1.x for older webpack versions.","message":"Version 0.2.0 updated to new Webpack API (hooks). If using Webpack <4, the plugin will not work.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use 'persistent: true' to avoid respawning on rebuilds, but beware that the process may linger.","message":"The plugin uses child_process.spawn synchronously under the hood; long-running processes may block the build.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Manually manage the child process reference and kill it when done.","message":"The 'persistent' option added in v0.2.1 may cause zombie processes if not handled correctly.","severity":"deprecated","affected_versions":">=0.2.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `const SpawnPlugin = require('webpack-spawn-plugin').default;` or enable esModuleInterop in tsconfig.","cause":"Using CommonJS require without proper default import handling.","error":"TypeError: SpawnPlugin is not a constructor"},{"fix":"Run `npm install --save-dev webpack-spawn-plugin`.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'webpack-spawn-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}