-
Notifications
You must be signed in to change notification settings - Fork 1
/
stencil.conf.js
89 lines (73 loc) · 2.04 KB
/
stencil.conf.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
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
80
81
82
83
84
85
86
87
88
89
var webpack = require('webpack');
/**
* Watch options for the core watcher
* @type {{files: string[], ignored: string[]}}
*/
var watchOptions = {
// If files in these directories change, reload the page.
files: [
'/templates',
'/lang',
],
//Do not watch files in these directories
ignored: [
'/assets/scss',
'/assets/less',
'/assets/css',
'/assets/dist',
]
};
/**
* Watch any custom files and trigger a rebuild
*/
function development() {
var devConfig = require('./webpack.dev.js');
// Rebuild the bundle once at bootup
webpack(devConfig).watch({}, (err, stats) => {
if (err) {
console.error(err.message, err.details);
}
if (stats.hasErrors()) {
console.error(stats.toString({ all: false, errors: true, colors: true }));
}
if (stats.hasWarnings()) {
console.error(stats.toString({ all: false, warnings: true, colors: true }));
}
process.send('reload');
});
}
/**
* Hook into the `stencil bundle` command and build your files before they are packaged as a .zip
*/
function production() {
var prodConfig = require('./webpack.prod.js');
webpack(prodConfig).run((err, stats) => {
if (err) {
console.error(err.message, err.details);
process.exit(1);
return;
}
if (stats.hasErrors()) {
console.error(stats.toString({ all: false, errors: true, colors: true }));
process.exit(1);
return;
}
if (stats.hasWarnings()) {
console.error(stats.toString({ all: false, warnings: true, colors: true }));
}
process.send('done');
});
}
if (process.send) {
// running as a forked worker
process.on('message', message => {
if (message === 'development') {
development();
}
if (message === 'production') {
production();
}
});
process.send('ready');
}
module.exports = { watchOptions };