forked from kartta-labs/iD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
51 lines (42 loc) · 1.24 KB
/
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
/* eslint-disable no-console */
const colors = require('colors/safe');
const gaze = require('gaze');
const StaticServer = require('static-server');
const buildAll = require('./build');
const buildData = require('./build_data');
const buildSrc = require('./build_src');
const buildCSS = require('./build_css');
const CSSFILES = ['css/**/*.css'];
const SRCFILES = ['modules/**/*.js'];
const DATAFILES = [
'data/**/*.{js,json}',
'data/core.yaml',
// ignore the output files of `buildData`
'!data/presets/categories.json',
'!data/presets/fields.json',
'!data/presets/presets.json',
'!data/presets.yaml',
'!data/taginfo.json',
'!data/territory-languages.json',
'!dist/locales/en.json'
];
buildAll()
.then(() => startServer());
function startServer() {
gaze(CSSFILES, (err, watcher) => {
watcher.on('all', () => buildCSS());
});
gaze(DATAFILES, (err, watcher) => {
watcher.on('all', () => {
buildData()
.then(() => buildSrc());
});
});
gaze(SRCFILES, (err, watcher) => {
watcher.on('all', () => buildSrc());
});
const server = new StaticServer({ rootPath: __dirname, port: 8080, followSymlink: true });
server.start(() => {
console.log(colors.yellow('Listening on ' + server.port));
});
}