-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.js
25 lines (20 loc) · 873 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const exec = require('child_process').exec;
function log(error, stdout, stderr) {
console.log(stdout);
console.error(stderr);
}
const os = require('os');
const osType = os.type();
const productionMode = process.argv[2] == 'production';
const mode = productionMode ? "production": "development";
const configFile = productionMode ? "webpack.prod.config.js": "webpack.local.config.js";
console.log(`Build in ${mode} mode on ${osType} system using ${configFile}`);
let command;
if (osType === 'Linux' || osType == 'Darwin')
command = `NODE_ENV=${mode} webpack -p --progress --colors --config ${configFile} --bail`;
else if (os.type() === 'Windows_NT')
command = `set NODE_ENV=${mode} & webpack -p --progress --colors --config ${configFile} --bail`;
else
throw new Error("Unsupported OS found: " + os.type());
console.log(command);
exec(command, log);