forked from sseletskyy/jspm-react-ava-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (30 loc) · 848 Bytes
/
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
'use strict'
const httpServer = require('http-server')
const port = process.env.PORT || 9080
let cache = 3600
let root = 'public'
if (process.env.NODE_ENV === 'production') {
root = 'dist-sfx'
console.log('running in production mode(with caching)-make sure you have "Disable cache (while DevTools is open)" checked in the browser to see the changes while developing')
} else {
cache = -1
}
if (process.env.NODE_ENV === 'staging') {
root = 'dist'
}
const server = httpServer.createServer({
root: root,
cache: cache,
robots: true,
fallback: '/',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true'
}
})
if (process.env.NODE_ENV !== 'production') {
require('chokidar-socket-emitter')({app: server.server})
}
server.listen(port, () => {
console.log('Listening on port ', port)
})