Giter Site home page Giter Site logo

execa-webpack-plugin's Introduction

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

execa-webpack-plugin's People

Contributors

alexander-akait avatar evilebottnawi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

execa-webpack-plugin's Issues

An in-range update of webpack is breaking the build 🚨

Version 4.18.0 of webpack was just published.

Branch Build failing 🚨
Dependency webpack
Current Version 4.17.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v4.18.0

Features

  • Upgrade webassemblyjs dependency
Commits

The new version differs by 12 commits.

  • ee7d948 4.18.0
  • de85978 Merge pull request #7732 from xtuc/chore-bump-webassemblyjs11
  • 4e02cac chore: bump webassemblyjs
  • 52e1630 bump webassemblyjs
  • e0e0061 Merge branch 'master' into chore-bump-webassemblyjs11
  • c9d6ec1 feat: remove wasm-opt
  • 075208d fix: merging
  • 38c3403 Merge remote-tracking branch 'upstream/master' into chore-bump-webassemblyjs11
  • 8214d56 chore: bump webassemblyjs
  • 59114c1 chore: bump webassemblyjs
  • b310b9b feat: remove LEB128 opt
  • f744c4a chore: bump webassemblyjs 1.6.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.