-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelopment_server.js
More file actions
45 lines (40 loc) · 1.18 KB
/
development_server.js
File metadata and controls
45 lines (40 loc) · 1.18 KB
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
const gaze = require('gaze');
const shell = require('shelljs');
const http = require('http');
const serveStatic = require('serve-static');
const finalhandler = require('finalhandler')
const request = require('request');
const port = process.env.PORT || 4200
function buildApp() { // gets run anytime the angular code changes
shell.exec('ng build');
}
function updateLogin() { // gets run anytime the login code or angular code changes.
shell.exec('cp src/login/* dist');
}
gaze([
'!srcp/app/login/**/*.{js,html}',
'src/**/*.{ts,css,html,json,}'
], function(err, watcher) {
watcher.on('all', function() {
console.log('\nrebuilding source...\n')
buildApp();
updateLogin();
console.log('\nsource rebuilt!\n')
})
})
gaze([
'src/login/**/*.{js,html}'
], function(err, watcher) {
watcher.on('all', function() {
updateLogin();
console.log('\nlogin page copied!\n')
})
})
const serve = serveStatic('dist', {
index: ['index.html', 'login.html'],
})
const server = http.createServer(function onRequest(req, res) {
serve(req, res, finalhandler(req, res))
})
server.listen(port)
console.log('Server started at: ' + port)