Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
webpack-shell-plugin-next
Advanced tools
fix webpack deprecated method. add typescript and other
This plugin allows you to run any shell commands before or after webpack 5 builds. This will work for both webpack 5.
Goes great with running cron jobs, reporting tools, or tests such as selenium, protractor, phantom, ect.
Webpack | webpack-shell-plugin-next |
---|---|
*-4.x | 1.* |
5.x | 2.* |
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-next
In webpack.config.js
:
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
...
module.exports = {
//...
plugins: [
new WebpackShellPluginNext({
onBuildStart:{
scripts: ['echo "Webpack Start"'],
blocking: true,
parallel: false
},
onBuildEnd:{
scripts: ['echo "Webpack End"'],
blocking: false,
parallel: true
}
})
]
//...
}
More example in webpack.config.ts
onBeforeBuild
: array of scripts to execute before every build.onBuildError
: array of scripts to execute when there is an error during compilation.onBuildStart
: configuration object for scripts that execute before a compilation.onBuildEnd
: configuration object for scripts that execute after files are emitted at the end of the compilation.onBuildExit
: configuration object for scripts that execute after webpack's process is complete. Note: this event also fires in webpack --watch
when webpack has finished updating the bundle.onWatchRun
: configuration object for scripts that execute when webpack's run watchonDoneWatch
: configuration object for scripts that execute after files are emitted at the end of the compilation with watch.onBeforeNormalRun
: configuration object for scripts that execute on normal run without --watch optiononAfterDone
: configuration object for scripts that execute after done.onFailedBuild
: configuration object for scripts that execute after error.onBeforeCompile
: configuration object for scripts that execute before complite.Default for all: {scripts: [],blocking: false,parallel: false}
blocking (onBeforeBuild, onBuildStart, onBuildEnd, onBuildExit, onBuildExit, onWatchRun)
: block webpack until scripts finish execution.parallel (onBeforeBuild, onBuildStart, onBuildEnd, onBuildExit, onBuildExit, onWatchRun)
: execute scripts in parallel, otherwise execute scripts in the order in which they are specified in the scripts array.Note: below combination is not supported.
{
blocking: true
parallel: true
}
Other global params
env
: Object with environment variables that will be applied to the executables Default: { }logging
: show output for internal messages. Default: trueswallowError
: ignore script errors (useful in watch mode) Default: falsedev
: 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: falsenew WebpackShellPlugin({
onBeforeNormalRun: {
// ...
},
dev: false,
safe: false,
logging: true
})
]
}
This project is written in TypeScript, and type declarations are included. You can take advantage of this if your project's webpack configuration is also using TypeScript (e.g. webpack.config.ts and webpack.config.js).
how to use functions in the queue?
{
{
scripts: [
// sync
() => {
console.log('run tTimeout 1');
setTimeout(() => console.log('end Timeout 1'), 1000);
},
// async
() => new Promise((resolve, reject) => {
console.log('run async tTimeout');
setTimeout(() => {
console.log('end async tTimeout');
resolve('ok');
}, 1000);
}),
],
blocking: true
}
}
// use exec
import * as os from 'os'
// ..
{
safe: os.platform() === 'win32', // by default spawn is used everywhere. If you have problems try using safe: true
scripts: [
//...
]
// ...
}
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!
[2.3.2] - 2024-08-07
FAQs
Run shell commands before and after webpack builds
We found that webpack-shell-plugin-next demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.