forked from tengbao/vanta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.build.js
33 lines (31 loc) · 929 Bytes
/
webpack.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
const webpack = require("webpack")
const webpackConfig = require("./webpack.config.js")
function timeStr(){
return '[' + new Date().toLocaleTimeString() + ']';
}
const compiler = webpack(webpackConfig)
let fileList = [];
for (let i in webpackConfig.entry) fileList.push(i);
function compilerCallback (err, stats) {
console.log(timeStr() + " Building " + fileList.join(', '))
if (stats.compilation.errors && stats.compilation.errors.length) {
console.log('COMPILATION ERROR')
console.log(stats.compilation.errors)
}
}
if (process.argv[2] == 'watch') {
const watching = compiler.watch({
// watchOptions
aggregateTimeout: 300,
poll: undefined
}, compilerCallback);
console.log(timeStr() + " Watching for changes... ");
(function wait() {
setTimeout(wait, 1000);
})();
// watching.close(() => {
// console.log("Watching Ended.");
// });
} else {
compiler.run(compilerCallback);
}