webpack-shell-plugin0.5.0 • Public • Published
Webpack Shell Plugin
This plugin allows you to run any shell commands before or after webpack builds. This will work for both webpack and webpack-dev-server.
Goes great with running cron jobs, reporting tools, or tests such as selenium, protractor, phantom, ect.
npm install --save-dev webpack-shell-plugin
const WebpackShellPlugin = ;moduleexports =......plugins:onBuildStart:'echo "Webpack Start"' onBuildEnd:'echo "Webpack End"'...
Insert into your webpack.config.js:
const WebpackShellPlugin = ;const path = ;var plugins = ;plugins;var config =entry:app: pathoutput:path: path // regular webpackfilename: 'bundle.js'devServer:contentBase: path // dev serverplugins: pluginsmodule:loaders:test: /\.js$/ loaders: 'babel'test: /\.scss$/ loader: 'style!css!scss?'test: /\.html$/ loader: 'html-loader'moduleexports = config;
Once the build finishes, a child process is spawned firing both a python and node script.
onBuildStart: array of scripts to execute on the initial build. Default: [ ]
onBuildEnd: array of scripts to execute after files are emitted at the end of the compilation. Default: [ ]
onBuildExit: array of scripts to execute after webpack's process is complete. Default: [ ]
dev: switch for development environments. This causes scripts to execute once. Useful for running HMR on webpack-dev-server or webpack watch mode. Default: true
safe: switches script execution process from spawn to exec. If running into problems with spawn, turn this setting on. Default: false
verbose: DEPRECATED enable for verbose output. Default: false
If opening a pull request, create an issue describing a fix or feature. Have your pull request point to the issue by writing your commits with the issue number in the message.
Make sure you lint your code by running
npm run lint and you can build the library by running
npm run build.
I appreciate any feed back as well, Thanks for helping!
Other Webpack Plugins
Also checkout our other webpack plugin WebpackBrowserPlugin.