forked from facebook/Rapid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
development_server.js
50 lines (41 loc) · 1.13 KB
/
development_server.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
/* eslint-disable no-console */
const colors = require('colors/safe');
const gaze = require('gaze');
const StaticServer = require('static-server');
const isDevelopment = process.argv[2] === 'develop';
const buildData = require('./build_data')(isDevelopment);
const buildSrc = require('./build_src')(isDevelopment);
const buildCSS = require('./build_css')(isDevelopment);
buildData()
.then(() => buildSrc());
buildCSS();
if (isDevelopment) {
gaze(['css/**/*.css'], (err, watcher) => {
watcher.on('all', () => {
buildCSS();
});
});
gaze([
'data/**/*.{js,json}',
'data/core.yaml',
// ignore the output files of `buildData`
'!data/territory-languages.json',
'!dist/locales/en.json'
],
(err, watcher) => {
watcher.on('all', () => {
buildData()
.then(() => buildSrc());
});
}
);
gaze(['modules/**/*.js'], (err, watcher) => {
watcher.on('all', () => {
buildSrc();
});
});
const server = new StaticServer({ rootPath: __dirname, port: 8080, followSymlink: true });
server.start(() => {
console.log(chalk.yellow('Listening on ' + server.port));
});
}