forked from facebook/Rapid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
development_server.js
62 lines (53 loc) · 1.72 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
51
52
53
54
55
56
57
58
59
60
61
62
/* 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(function () {
return buildSrc();
});
buildCSS();
if (isDevelopment) {
gaze(['css/**/*.css'], function(err, watcher) {
watcher.on('all', function() {
buildCSS();
});
});
gaze([
'data/**/*.{js,json}',
'data/core.yaml',
'data/rapid_config.yaml',
// ignore the output files of `buildData`
'!data/presets/categories.json',
'!data/rapid_config.json',
'!data/presets/fields.json',
'!data/presets/presets.json',
'!data/presets.yaml',
'!data/taginfo.json',
'!data/territory-languages.json',
'!dist/locales/en.json'
],
function(err, watcher) {
watcher.on('all', function() {
buildData()
.then(function () {
// need to recompute js files when data changes
buildSrc();
});
});
}
);
gaze(['modules/**/*.js'], function(err, watcher) {
watcher.on('all', function() {
buildSrc();
});
});
const server = new StaticServer({ rootPath: __dirname, port: 8080, followSymlink: true });
server.start(function () {
console.log(chalk.yellow('Listening on ' + server.port));
});
}