Created
December 10, 2017 20:23
-
-
Save jprivillaso/680583b26cc13b1f9a80aff6db52047b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const webpackAppCodeConfig = './webpack/concurrent/webpack.concurrent-app.js'; | |
const webpackAppStylesConfig = './webpack/concurrent/webpack.concurrent-styles.js'; | |
const NODE_ENV = process.env.NODE_ENV || 'development'; | |
const BUILD_PIPELINE = [ webpackAppStylesConfig, webpackAppCodeConfig ]; | |
console.log(`Running webpack build through API. Env [${NODE_ENV}]`); | |
const runAsyncBuild = () => { | |
const { fork } = require('child_process'); | |
for (let i = 0; i < BUILD_PIPELINE.length; i++) { | |
const childProcess = fork(BUILD_PIPELINE[i]); | |
childProcess.on('message', ({message, processName}) => { | |
if (message === 'FINISHED_BUILD') { | |
console.log(`Killing process ${processName}`); | |
childProcess.kill('SIGINT'); | |
} else { | |
console.log(`Message from ${processName}: \n ${message}`); | |
} | |
}); | |
} | |
}; | |
runAsyncBuild(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment