-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
89 lines (81 loc) · 2.68 KB
/
config.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Project config file includes dev/prod and frontend/backend
*/
var path = require('path')
var _ = require('lodash')
var backendBase = {
// Root path of server
root: path.normalize(__dirname),
// Server port
port: process.env.PORT || 8080,
// Secret for session, you will want to change this and make it an environment variable
secrets: {
session: process.env.SECRET || 'wundercast-web-secret'
},
// List of user roles
userRoles: ['admin', 'user'],
// MongoDB connection options
mongo: {
options: {
db: {
safe: true
}
}
}
}
var development = {
frontend: {
port: 8081,
assetsRoot: path.resolve(__dirname, './client/src'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': { target: 'http://server:' + backendBase.port, changeOrigin: true },
'/socket.io': { target: 'http://server:' + backendBase.port, changeOrigin: true, ws: true }
},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
},
backend: _.merge({}, backendBase, {
mongo: {
uri: 'mongodb://mongo/wundercast-web-dev'
}
})
}
var production = {
frontend: {
index: path.resolve(__dirname, './client/dist/index.html'),
assetsRoot: path.resolve(__dirname, './client/dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
cssSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css']
},
backend: _.merge({}, backendBase, {
// whether backend servers the frontend, you can use nginx to server frontend and proxy to backend services
// if set to true, you need no web services like nginx
serverFrontend: true,
// Server IP
ip: process.env.APP_HOST || process.env.APP_IP || process.env.HOST || process.env.IP,
// Server port
port: process.env.APP_PORT || process.env.PORT,
// MongoDB connection options
mongo: {
uri: process.env.MONGODB_URI || process.env.MONGOHQ_URI ||
'mongodb://localhost/wundercast-web'
},
// frontend folder
frontend: path.resolve(__dirname, './client/dist')
})
}
var config = process.env.NODE_ENV === 'production' ? production : development
module.exports = _.assign({}, config)