-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
38 lines (33 loc) · 1.08 KB
/
webpack.config.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
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const buildConf = require('./build/config');
const getWebpackConfig = require(path.join(buildConf.BUILD_PATH, 'compile', 'webpack.compile'));
const argv = require('yargs').argv;
const ENV = argv.env;
module.exports = {
compile(env) {
return getWebpackConfig(env)
.then((logicConfig) => {
let startTime = + new Date();
console.log('> Start build logic code!');
return new Promise((resolve, reject) => {
let compiler = webpack(logicConfig, (err, stats) => {
let endTime = + new Date();
let wasteTime = Math.floor((endTime - startTime) / 1000);
if(err) {
reject(err);
} else{
resolve(compiler);
console.log(`> Logic code build over! all ${wasteTime}s`)
}
})
});
}, (err) => {
console.log(err)
})
}
};
if (ENV !== 'dev') {
module.exports.compile(ENV);
}