forked from javascript-tutorial/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.js
More file actions
executable file
·79 lines (64 loc) · 1.63 KB
/
webpack.js
File metadata and controls
executable file
·79 lines (64 loc) · 1.63 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var webpack = require('webpack');
var gp = require('gulp-load-plugins')();
var notifier = require('node-notifier');
module.exports = function() {
return function(callback) {
var config = require('config').webpack;
webpack(config, function(err, stats) {
if (!err) {
// errors in files do not stop webpack watch
// instead, they are gathered, so I get the first one here (if no other)
var jsonStats = stats.toJson();
err = jsonStats.errors[0];
}
if (err) {
notifier.notify({
message: err
});
gp.util.log(err);
if (!config.watch) callback(err);
return;
}
/*
Log profile
console.log( stats.toJson().modules.map(function(mod) {
return {
identifier: mod.identifier,
name: mod.name,
profile: mod.profile
};
}) );
*/
/*
For webpack analyse
require('fs').writeFileSync('/tmp/webpack.json', JSON.stringify(stats.toJson()));
*/
gp.util.log('[webpack]', stats.toString({
hash: false,
version: false,
timings: true,
assets: true,
chunks: false,
modules: false,
cached: true,
colors: true
}));
/*
Log profile and all details
gp.util.log('[webpack]', stats.toString({
hash: false,
version: false,
timings: true,
assets: true,
chunks: true,
chunkModules: true,
modules: true,
cached: true,
colors: true,
profile: true
}));
*/
if (!config.watch) callback();
});
};
};