-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbundle.js
More file actions
44 lines (35 loc) · 892 Bytes
/
Copy pathbundle.js
File metadata and controls
44 lines (35 loc) · 892 Bytes
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
/**
* Copyright (c) 2015-present, Alibaba Group Holding Limited.
* All rights reserved.
*/
'use strict';
var chalk = require('chalk');
var path = require('path');
var fs = require('fs');
var Promise = require('promise');
var webpack = require('webpack');
/**
* Builds the javascript bundle.
*/
function bundle(argv, config) {
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
return new Promise((resolve, reject) => {
_bundle(argv, config, resolve, reject);
});
}
function _bundle(argv, config, resolve, reject) {
var webpackConfig = require(config.getWebpackConfig(argv[1]));
var compiler = webpack(webpackConfig);
compiler.run(function(err, stats) {
if (err) {
reject(err);
return;
}
var options = {
colors: true
};
console.log(stats.toString(options));
resolve(stats);
});
}
module.exports = bundle;