forked from ordercloud-api/angular-buyer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (37 loc) · 1.5 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
'use strict';
var config = require('./gulp.config');
var express = require('express'),
cookieParser = require('cookie-parser'),
env = process.env.NODE_ENV = process.env.NODE_ENV || 'dev',
app = express(),
port = process.env.PORT || 451;
if (config.saas.getAppConfig) {
app.use(cookieParser());
app.use(config.saas.getAppConfig());
app.use('/assets/styles', config.saas.styles.serverLess());
}
switch(env) {
case 'production':
console.log('*** PROD ***');
app.use(express.static(config.root + config.compile.replace('.', '')));
app.get('/*', function(req, res) {
res.sendFile(config.root + config.compile.replace('.', '') + 'index.html');
});
break;
default:
console.log('*** DEV ***');
// Host bower_files
app.use('/bower_files', express.static(config.root + config.bowerFiles.replace('.', '')));
// Host unminfied javascript files
app.use(express.static(config.root + config.build.replace('.', '')));
// Host unchanged html files (look for saas overrides first)
app.use(express.static(config.root + config.src.replace('.', '') + 'app/saas/'));
// Host unchanged html files
app.use(express.static(config.root + config.src.replace('.', '') + 'app/'));
app.get('/*', function(req, res) {
res.sendFile(config.root + config.build.replace('.', '') + 'index.html');
});
break;
}
app.listen(port);
console.log('Listening on port ' + port + '...');