1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | module.exports = (port, env = process.env.WEBPACK_BUILD_ENV) => {
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | const defaultPort =
|
16 | process.env.WEBPACK_BUILD_ENV === 'prod' &&
|
17 | typeof process.env.SERVER_PORT !== 'undefined'
|
18 | ? process.env.SERVER_PORT
|
19 | : typeof __SERVER_PORT__ !==
|
20 | 'undefined'
|
21 | ? __SERVER_PORT__
|
22 | : process.env.SERVER_PORT;
|
23 |
|
24 | if (typeof port === 'object') {
|
25 | if (!env) env = 'prod';
|
26 | if (typeof port[env] !== 'undefined') return port[env];
|
27 | return defaultPort;
|
28 | }
|
29 |
|
30 | if (typeof port !== 'undefined' && typeof port !== 'boolean') return port;
|
31 |
|
32 | return defaultPort;
|
33 | };
|