-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
37 lines (30 loc) · 780 Bytes
/
dev.js
File metadata and controls
37 lines (30 loc) · 780 Bytes
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
// Simple build script for development.
const chokidar = require('chokidar');
const spawn = require('cross-spawn');
function run (script) {
spawn('npm', ['run', script], { stdio: 'inherit' });
}
run('dev');
run('rollup');
run('css');
run('pug');
chokidar.watch('src', {ignored: /(^|[\/\\])\../}).on('all', (event, path) => {
if (event === 'change') {
console.log(event, path);
if (path.endsWith('.js')) {
run('rollup');
}
if (path.endsWith('.styl')) {
run('css');
}
if (path.endsWith('.pug')) {
run('pug');
}
if (path.endsWith('server.js')) {
console.log('Server code modified, exiting');
process.exit();
}
}
});
// Load the server application
require('child_process').fork('./src/server/server.js');