dk-webpack-parallel-simple
TypeScript icon, indicating that this package has built-in type declarations

3.4.5 • Public • Published

Simple lib for parallel Webpack builds

coverage npm license size

[!WARNING]
It's fine if you use this library from NPM package with a static versioning in case you want it for some pet-project or to test it's capabilities.

But for production use it's strongly recommended to create a fork, because I do not write Changelogs and may break / add some functionality without notice.

Motivation

The existing library parallel-webpack is not maintained, has huge codebase, does not support custom communication between processes, does not show low-level errors, requires separate file with configs.

This one is a light alternative based on internal Node.js child_process fork

Supports TypeScript configs

Usage

import { ChildProcess } from 'child_process';
import { run, TypeConfig } from 'dk-webpack-parallel-simple';

let childProcesses: Array<ChildProcess> = [];

const parallelConfig: TypeConfig = {
    onInit(processes: Array<ChildProcess>) { childProcesses = processes; },
    bailOnError: false,
    configPaths: [
        path.resolve(__dirname, './client.config'),
        path.resolve(__dirname, './server.config'),
    ],
    afterFirstBuild() {
        childProcesses.forEach((childProcess) => {
            childProcess.send('SOME_MESSAGE');
        });
        
        // ... maybe start Node.js server, browser reload service, file generation service
    },
};

run(parallelConfig);

Params

bailOnError - if true all processes will be terminated on the first error

configPaths - array of config files' paths

afterFirstBuild (optional) - callback that called after first compiler run on every config passed

onInit (optional) - passes instances of forked processes so you are able to send messages to your webpack processes and get answers

Readme

Keywords

none

Package Sidebar

Install

npm i dk-webpack-parallel-simple

Weekly Downloads

6

Version

3.4.5

License

MIT

Unpacked Size

15.7 kB

Total Files

33

Last publish

Collaborators

  • dkazakov8