execa-webpack-plugin
A better child_process
for webpack
.
Installation
npm i -D execa-webpack-plugin
Usage
webpack.config.js
const ExecaPlugin = ; moduleexports = plugins: onBeforeRun: args: "build" cmd: "del" options: cwd: process ;
Note: list of command options.
Options
Name | Type | Default | Description |
---|---|---|---|
on(NameOfHook) |
{Array} |
[] |
Array of commands to execute on the hook. |
bail |
{Boolean} |
compiler.options.bail |
Report the first error as a hard error instead of tolerating it. |
dev |
{Boolean} |
true |
Switch for development environments. This causes scripts to execute once. Useful for running HMR on webpack-dev-server or webpack watch mode. |
on(NameOfHook)
List of hooks.
The name of hook contains: on
+ hook name (first character in upper case).
Examples: onBeforeRun
, onRun
, onWatchRun
, onCompile
and etc.
webpack.config.js
moduleexports = plugins: onBeforeRun: args: "build" cmd: "del" onCompile: args: "check" cmd: "command" // Support nested command onDone: args: args: "arg" cmd: "command-return-argument" "other-argument" args: "arg" cmd: "command-return-other-argument" cmd: "command" ;
bail
Fail out on the first error instead of tolerating it. To enable it:
webpack.config.js
moduleexports = plugins: bail: true onBeforeRun: args: "build" cmd: "del" ;
dev
If you want to run command(s) in watch
mode every time you can set dev
option to false.
webpack.config.js
moduleexports = plugins: dev: false onBeforeRun: args: "build" cmd: "del" ;
Examples
Set logger level
webpack.config.js
moduleexports = infrastructureLogging: level: "warn" plugins: onBeforeRun: args: "build" cmd: "del" ;
Thanks
- execa - API.