webpack-shell-plugin-alt
Advanced tools
Weekly downloads
Changelog
Update Dependencies
Update Dependencies to address security warnings.
Update the webpack.config we use for testing for latest version of Webpack.
Readme
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.
This plugin is meant for running simple command line executions. It is not meant to be a task management tool.
npm install --save-dev webpack-shell-plugin-alt
In webpack.config.js
:
import WebpackShellPlugin from 'webpack-shell-plugin-alt';
module.exports = {
...
...
plugins: [
new WebpackShellPlugin({onBuildStart:['echo "Webpack Start"'], onBuildEnd:['echo "Webpack End"']})
],
...
}
Insert into your webpack.config.js:
import WebpackShellPlugin from 'webpack-shell-plugin-alt';
const path = require('path');
var plugins = [];
plugins.push(new WebpackShellPlugin({
onBuildStart: ['echo "Starting"'],
onBuildEnd: ['python script.py && node script.js']
}));
var config = {
entry: {
app: path.resolve(__dirname, 'src/app.js')
},
output: {
path: path.resolve(__dirname, 'dist'), // regular webpack
filename: 'bundle.js'
},
devServer: {
contentBase: path.resolve(__dirname, 'src') // dev server
},
plugins: plugins,
module: {
loaders: [
{test: /\.js$/, loaders: 'babel'},
{test: /\.scss$/, loader: 'style!css!scss?'},
{test: /\.html$/, loader: 'html-loader'}
]
}
}
module.exports = 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. Note: this event also fires in webpack --watch
when webpack has finished updating the bundle. Default: [ ]onCompile
: array of scripts to execute on every compile. 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: truesafe
: switches script execution process from spawn to exec. If running into problems with spawn, turn this setting on. Default: falseverbose
: DEPRECATED enable for verbose output. Default: falseIf 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!
Also checkout our other webpack plugin WebpackBrowserPlugin.
Yair Tavor
FAQs
Run shell commands before and after webpack builds
The npm package webpack-shell-plugin-alt receives a total of 340 weekly downloads. As such, webpack-shell-plugin-alt popularity was classified as not popular.
We found that webpack-shell-plugin-alt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.