execa-webpack-plugin
A better `child_process` for `webpack`
Last updated 8 months ago by evilebottnawi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install execa-webpack-plugin 
SYNC missed versions from official npm registry.

execa-webpack-plugin

NPM version Build Status dependencies Status devDependencies Status

A better child_process for webpack.

Installation

npm i -D execa-webpack-plugin

Usage

webpack.config.js

const ExecaPlugin = require("execa-webpack-plugin");

module.exports = {
  plugins: [
    new ExecaPlugin({
      onBeforeRun: [
        {
          args: ["build"],
          cmd: "del",
          options: {
            cwd: process.cwd()
          }
        }
      ]
    })
  ]
};

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

module.exports = {
  plugins: [
    [
      new ExecaPlugin({
        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

module.exports = {
  plugins: [
    [
      new ExecaPlugin({
        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

module.exports = {
  plugins: [
    new ExecaPlugin({
      dev: false,
      onBeforeRun: [
        {
          args: ["build"],
          cmd: "del"
        }
      ]
    })
  ]
};

Examples

Set logger level

webpack.config.js

module.exports = {
  infrastructureLogging: {
    level: "warn"
  },
  plugins: [
    new ExecaPlugin({
      onBeforeRun: [
        {
          args: ["build"],
          cmd: "del"
        }
      ]
    })
  ]
};

Thanks

Changelog

License

Current Tags

  • 6.0.2                                ...           latest (8 months ago)

20 Versions

  • 6.0.2                                ...           8 months ago
  • 6.0.1                                ...           8 months ago
  • 6.0.0                                ...           10 months ago
  • 5.0.0                                ...           a year ago
  • 4.0.1                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 4
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |