forked from anthonydugois/polynom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.js
33 lines (27 loc) · 813 Bytes
/
variables.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
process.env.NODE_ENV = "development"
if (process.argv.includes("--production")) {
process.env.NODE_ENV = "production"
}
const __PROD__ = process.env.NODE_ENV === "production"
const __DEV__ = !__PROD__
const __OUTPUT_DIR__ = "dist"
const __SERVER_PROTOCOL__ = "http://"
const __SERVER_HOST__ = "localhost"
const __SERVER_PORT__ = "3000"
const variables = {
"process.env": { "NODE_ENV": JSON.stringify(process.env.NODE_ENV) },
__PROD__,
__DEV__,
__OUTPUT_DIR__,
__SERVER_PROTOCOL__,
__SERVER_HOST__,
__SERVER_PORT__,
__SERVER_URL__: `${ __SERVER_PROTOCOL__ }${ __SERVER_HOST__ }`,
}
if (__SERVER_PORT__) {
variables.__SERVER_URL__ += `:${ __SERVER_PORT__ }`
}
export default variables
export function defineVariables() {
Object.keys(variables).forEach((k) => global[k] = variables[k])
}