bundle.js
1.0 KB
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
/**
* React Starter Kit (http://www.reactstarterkit.com/)
*
* Copyright © 2014-2015 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import webpack from 'webpack';
// import webpackConfig from './webpack.config';
import webpackConfig from './webpack.config.production';
/**
* Bundles JavaScript, CSS and images into one or more packages
* ready to be used in a browser.
*/
function bundle() {
return new Promise((resolve, reject) => {
const bundler = webpack(webpackConfig);
let bundlerRunCount = 0;
function onComplete(err, stats) {
if (err) {
return reject(err);
}
console.log(stats.toString(webpackConfig[0].stats));
if (++bundlerRunCount === (global.WATCH ? webpackConfig.length : 1)) {
return resolve();
}
}
if (global.WATCH) {
bundler.watch(200, onComplete);
} else {
bundler.run(onComplete);
}
});
}
export default bundle;