-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
43 lines (39 loc) · 1.19 KB
/
webpack.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
const webpack = require('webpack');
const environment = process.env.ENVIRONMENT;
const port = process.env.PORT;
let ENVIRONMENT_VARIABLES = {
'process.env.ENVIRONMENT': JSON.stringify(environment || 'development'),
'process.env.PORT': JSON.stringify(port || '3042'),
};
console.log('environment:::::', environment);
if (environment === 'test') {
ENVIRONMENT_VARIABLES = {
'process.env.ENVIRONMENT': JSON.stringify(environment),
'process.env.PORT': JSON.stringify(port || '3042'),
};
} else if (environment === 'production') {
ENVIRONMENT_VARIABLES = {
'process.env.ENVIRONMENT': JSON.stringify(environment),
'process.env.PORT': JSON.stringify(port || '3042'),
};
} else {
ENVIRONMENT_VARIABLES = {
'process.env.ENVIRONMENT': JSON.stringify(environment || 'development'),
'process.env.PORT': JSON.stringify(port || '3042'),
};
}
module.exports = {
entry: './index.js',
output: {
path: '/dist', //path.resolve(__dirname, 'dist'),
filename: 'api.bundle.js',
},
target: 'node',
'mode': environment,
experiments: {
topLevelAwait: true
},
plugins: [
new webpack.DefinePlugin(ENVIRONMENT_VARIABLES),
],
};