forked from bdefore/universal-redux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_es6.js
52 lines (43 loc) · 1.24 KB
/
build_es6.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
process.env.NODE_ENV = 'production';
const fs = require('fs');
const webpack = require('webpack');
const userConfig = require('./user-config');
const config = require('./merge-configs')(userConfig);
const buildStats = false;
const outputStatsPath = './webpack-stats.json';
const webpackConfig = config.webpack.config;
console.log('\nBuilding webpack bundle...');
webpack(webpackConfig, (err, stats) => {
if (err) {
console.log('Webpack build had fatal error:', err);
return;
}
const options = {
hash: true,
version: true,
timings: true,
assets: true,
chunks: false,
colors: true
};
console.log('Webpack compile was successful.');
const jsonStats = stats.toJson();
if (jsonStats.errors.length > 0) {
console.log('Webpack had errors.');
options.errors = true;
}
if (jsonStats.warnings.length > 0) {
console.log('Webpack had warnings.');
options.warnings = true;
}
console.log(stats.toString(options));
if (buildStats) {
fs.writeFile(outputStatsPath, JSON.stringify(stats.toJson()), (writeError) => {
if (writeError) {
return console.log(writeError);
}
console.log('Webpack output stats were saved to', outputStatsPath);
});
}
});