forked from bigcommerce/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stencil.conf.js
71 lines (60 loc) · 1.59 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');
var webpackConfig = require('./webpack.conf.js');
/**
* 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() {
// Rebuild the bundle once at bootup
webpack(webpackConfig).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() {
webpackConfig.watch = false;
webpackConfig.devtool = false;
webpackConfig.plugins.push(new webpack.optimize.DedupePlugin());
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ comments: false }));
webpack(webpackConfig).run(err => {
if (err) {
console.error(err.message, err.details);
}
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 };