-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
35 lines (26 loc) · 1.14 KB
/
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
26
27
28
29
30
31
32
33
34
35
// More info on Webpacks Node API here: https://webpack.github.io/docs/node.js-api.html
// Allowing console calls below since this is a build file.
/*eslint-disable no-console*/
import webpack from 'webpack';
import webpackConfig from '../webpack.config.prod';
import colors from 'colors';
process.env.NODE_ENV = 'production'; // this assures the Babel dev config (for hot reloading) doesnt apply
console.log('Generating minified bundle for production via Webpack. This will take a moment');
webpack(webpackConfig).run((err, stats) => {
if (err) { // so a fatal error occurred. stop here.
console.log(err.bold.red);
return 1;
}
const jsonStats = stats.toJson();
if (jsonStats.hasErrors) {
return jsonStats.errors.map(error => console.log(error.red));
}
if (jsonStats.hasWarnings) {
console.log('Webpack generated teh following warnings: '.bold.yellow);
jsonStats.warnings.map(warning => console.log(warning.yellow));
}
console.log('Webpack stats: $s={stats}');
// if we got this far, the build succeeded.
console.log('Your app has been compiled in production mdoe and written to /dist. It\'s ready');
return 0;
});