0.0.2 • Published 6 years ago

child-process-webpack-plugin v0.0.2

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

Child Process Webpack Plugin

Webpack plugin for starting child processes after each build.

Installation

$ npm install child-process-webpack-plugin

Basic usage

In your webpack.config.js:

const ChildProcessPlugin = require('child-process-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new ChildProcessPlugin('echo Hello!')
    ]
    // ...
}

Options

new ChildProcessPlugin(config: array | object | string)

Ideally config is an array of child process configurations. Each config is an object with the following keys:

KeyTypeDefault valueDescription
commandString''The command to be executed
onceBooleanfalseRun the command only after the first build (true makes sense only in watch mode)
prefixString''Each line of the process output gets prefixed with this string
cwdString'.'Working directory the process will run in
envObject{PATH:process.env.PATH}Environment variables for the child process

If config is an object, it's interpreted as an array with a single configuration:

new ChildProcessPlugin([config])

If config is a string, it's interpreted as a single command:

new ChildProcessPlugin([{
    command: config
}])

If you don't like the array syntax, you can create multiple instances:

module.exports = {
    // ...
    plugins: [
        new ChildProcessPlugin(config1),
        new ChildProcessPlugin(config2)
    ]
    // ...
}

Example

For a complete example check the test folder.