{"_id":"@allroundexperts/run-node-webpack-plugin","name":"@allroundexperts/run-node-webpack-plugin","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@allroundexperts/run-node-webpack-plugin","version":"1.0.0","description":"Webpack plugin that starts a node.js script after webpack compilation and smartly restarts it after subsequent recompilations","author":{"name":"rdoo"},"license":"MIT","main":"dist/cjs.js","types":"dist/index.d.ts","keywords":["run","start","restart","node","nodejs","script","server","webpack","plugin"],"homepage":"https://github.com/rdoo/run-node-webpack-plugin","repository":{"type":"git","url":"git+https://github.com/rdoo/run-node-webpack-plugin.git"},"bugs":{"url":"https://github.com/rdoo/run-node-webpack-plugin/issues"},"scripts":{"build":"tsc","prebuild":"rimraf dist","test":"mocha -r ts-node/register test/**/*.test.ts"},"devDependencies":{"@types/chai":"4.2.12","@types/mocha":"8.0.3","@types/node":"14.10.1","@types/sinon":"9.0.5","chai":"4.2.0","mocha":"8.1.3","rimraf":"3.0.2","sinon":"9.0.3","ts-node":"9.0.0","typescript":"4.0.2","webpack":"5.0.0-beta.30"},"peerDependencies":{"webpack":"^4.0.0 || ^5.0.0"},"gitHead":"8996dd84fd01c293082dce7d5ddb644871e8d42a","_id":"@allroundexperts/run-node-webpack-plugin@1.0.0","_nodeVersion":"16.17.1","_npmVersion":"8.15.0","dist":{"integrity":"sha512-d85rNaEj/izx+vSyCFC1CCTHWCHC8xmQmmFCW9HXvYwfMj2DcKJNX3aU3gObVkUB3ewi0IdiW8h3nJOIuFB59g==","shasum":"d54b7923375a216c58360b8fb2aeafcc93206ecd","tarball":"https://registry.npmjs.org/@allroundexperts/run-node-webpack-plugin/-/run-node-webpack-plugin-1.0.0.tgz","fileCount":9,"unpackedSize":17477,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFZXDoQJQ0Iy/RpUdTtZzAkMr7nmgsB9zjcGNFp+nvRwAiBwmp+t7vjlDs2oU9ESPq3OV3Ey4CFRMGidW1BNueyzDA=="}]},"_npmUser":{"name":"allroundexperts","email":"allroundexperts@gmail.com"},"directories":{},"maintainers":[{"name":"allroundexperts","email":"allroundexperts@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/run-node-webpack-plugin_1.0.0_1694298015155_0.19325713476228557"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-09T22:20:15.056Z","1.0.0":"2023-09-09T22:20:15.413Z","modified":"2023-09-09T22:20:15.688Z"},"maintainers":[{"name":"allroundexperts","email":"allroundexperts@gmail.com"}],"description":"Webpack plugin that starts a node.js script after webpack compilation and smartly restarts it after subsequent recompilations","homepage":"https://github.com/rdoo/run-node-webpack-plugin","keywords":["run","start","restart","node","nodejs","script","server","webpack","plugin"],"repository":{"type":"git","url":"git+https://github.com/rdoo/run-node-webpack-plugin.git"},"author":{"name":"rdoo"},"bugs":{"url":"https://github.com/rdoo/run-node-webpack-plugin/issues"},"license":"MIT","readme":"# Run Node Webpack Plugin\nWebpack plugin that starts a node.js script after webpack compilation and smartly restarts it after subsequent recompilations\n\n## Installation\n```sh\n$ npm install run-node-webpack-plugin --save-dev\n```\n\n## Usage\n**webpack.config.js**\n```js\nconst RunNodeWebpackPlugin = require('run-node-webpack-plugin');\n\nmodule.exports = {\n    // ...\n    plugins: [\n        new RunNodeWebpackPlugin()\n    ],\n    // ...\n};\n```\nPlugin's primary use case is when you are developing a node.js app with webpack and want that app to restart whenever webpack finishes compiling its bundle.\n\n## Advantages\n- More efficient in webpack development scenarios than `nodemon`, `pm2`, `forever`, etc.\n- Contrary to other similar plugins can restart script only when an actual change in webpack bundle occurs\n- Rich customization possible via plugin options\n\n## Options\nAll the options are optional and are configured so that in most cases you should not want to change them.\n\n### `scriptToRun: string`\nNode script which will be run after webpack compilations. You can provide a file name from webpack output or path to an external file.\n\n**Default:** By default when webpack config contains only one output file then that file will be run. If more files are present then file named `server.js` or `index.js` (whichever exists) will be run\n\n**Examples**\n```js\n// ...\nentry: {\n    server: 'src/server.js',\n    otherScript: 'src/otherScript.js'\n},\noutput: {\n    path: 'build',\n    filename: '[name].js'\n},\n// ...\nplugins: [\n    new RunNodeWebpackPlugin({ scriptToRun: 'otherScript.js' })\n],\n// ...\n```\nIn this example by default `server.js` would be run but you can change it to `otherScript.js`.\n```js\n// ...\nentry: 'src/index.js',\noutput: {\n    path: 'build',\n    filename: 'webpackOutputScript.js'\n},\n// ...\nplugins: [\n    new RunNodeWebpackPlugin({ scriptToRun: './path/to/external/file.js' })\n],\n// ...\n```\nIn this example by default `webpackOutputScript.js` would be run but you can change it to an external script not connected with webpack build process, for example: `./path/to/external/file.js`.\n\n```js\n// ...\nentry: {\n    server: 'src/server.js',\n},\noutput: {\n    path: 'build',\n    filename: '[name].js'\n},\n// ...\nplugins: [\n    new RunNodeWebpackPlugin({\n        scriptToRun: 'server.js',\n        processArgs: {\n            execArgv:['--inspect-brk']\n        } \n    })\n],\n// ...\n```\nIn this example a debugger is attached when running the script.\n\n### `runOnlyOnChanges: boolean`\nWhen set to `true` plugin will run the script only when an actual change in webpack output files happens, otherwise after every webpack compilation.\n\n**Default: `true`**\n\n### `scriptsToWatch: string[]`\nArray of webpack ouput file names that plugin should watch for changes. Works only if `runOnlyOnChanges` is set to `true`.\n\n**Default:** By default plugin watches all webpack output files\n\n**Examples**\n```js\n// ...\nentry: {\n    server: 'src/server.js',\n    script: 'src/script.js'\n},\noutput: {\n    path: 'build',\n    filename: '[name].js'\n},\n// ...\nplugins: [\n    new RunNodeWebpackPlugin({ scriptsToWatch: ['server.js'] })\n],\n// ...\n```\nIn this example by default plugin would run `server.js` whenever a change to `server.js` or `script.js` happens but you can exclude `script.js` from change detection by providing only `server.js` to `scriptsToWatch` option.\n\n### `runOnlyInWatchMode: boolean`\nWhen set to `true` plugin will run the script only when webpack is in a watch mode.\n\n**Default: `false`**\n\n### `runOnlyInNormalMode: boolean`\nWhen set to `true` plugin will run the script only when webpack is NOT in a watch mode.\n\n**Default: `false`**\n\n### `ignoreErrors: boolean`\nWhen set to `true` plugin will try to run the script even when webpack compilation throws errors.\n\n**Default: `false`**\n\n### `nodeArgs: string[]`\nList of string arguments to pass to the node script.\n[See more information](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)\n\n**Default: `[]`**\n\n### `processArgs: Object`\nList of options to pass to the process executing the node script.\n[See more information](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)\n\n**Default: `[]`**\n\n## License\nCopyright © 2018 [rdoo](https://github.com/rdoo). Released under the MIT license.\n","readmeFilename":"README.md"}