forked from bigcommerce/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stencil.conf.js
71 lines (59 loc) · 1.46 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
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 => {
if (err) {
console.error(err.message, err.details);
}
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 => {
if (err) {
console.error(err.message, err.details);
process.exit(1);
return;
}
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 };