-
Notifications
You must be signed in to change notification settings - Fork 352
/
watch.js
62 lines (53 loc) · 1.68 KB
/
watch.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
const { parallel, series, watch } = require('gulp');
const electron = require('./electron');
const hotreload = require('./hotreload');
const assets = require('./assets');
const scripts = require('./scripts');
function watchMainScripts() {
return watch(['build/src/main/**/*.js'], series(electron.stop, electron.start));
}
function watchRendererScripts() {
return watch(['build/src/renderer/**/*.js'], series(hotreload.reload));
}
function watchCss() {
return watch(['src/renderer/**/*.css'], series(assets.copyCss, hotreload.reload));
}
function watchConfig() {
return watch(['src/config.json'], series(assets.copyConfig, hotreload.reload));
}
function watchHtml() {
return watch(
['src/renderer/index.html'],
series(assets.copyHtml, hotreload.inject, hotreload.reload),
);
}
function watchStaticAssets() {
return watch(['assets/**'], series(assets.copyStaticAssets, hotreload.reload));
}
watchMainScripts.displayName = 'watch-main-scripts';
watchRendererScripts.displayName = 'watch-renderer-scripts';
watchCss.displayName = 'watch-css';
watchConfig.displayName = 'watch-config';
watchHtml.displayName = 'watch-html';
watchStaticAssets.displayName = 'watch-static-assets';
exports.start = series(
// copy all assets first
assets.copyAll,
// make an incremental script compiler running in watch mode
scripts.makeWatchCompiler(
// set up hotreload, run electron and begin watching filesystem for changes, after the first
// successful build
series(
hotreload.start,
electron.start,
parallel(
watchMainScripts,
watchRendererScripts,
watchCss,
watchConfig,
watchHtml,
watchStaticAssets,
),
),
),
);