-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
48 lines (47 loc) · 1.47 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
44
45
46
47
48
const path = require('path')
const env = process.env.NODE_ENV
const inDev = env === 'dev' || env === 'development'
const webpack = require('webpack')
module.exports = (env, argv) => ({
mode: !inDev ? 'production' : 'development',
devtool: !inDev ? false : 'source-map',
entry: {
core: './server/src/js/core.js',
webchat: './server/src/js/webchat.js',
chart: './server/src/js/components/chart.js',
'latest-levels-auto-refresh': './server/src/js/components/latest-levels-auto-refresh',
'stations-overview': './server/src/js/pages/stations-overview'
},
output: {
path: path.resolve(__dirname, 'server/dist/js')
},
module: {
rules: [
{
// Default exclude removes all node_modules but d3 is now distributed es6 so include d3 (& our own src) in transpile
include: mPath => mPath.indexOf('server/src') > -1 || mPath.indexOf('node_modules/d3') > -1 || mPath.indexOf('node_modules/internmap') > -1,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3
}
]
]
}
}
}
]
},
target: ['web', 'es5'],
plugins: [
new webpack.DefinePlugin({
'process.env.GA4_ID': JSON.stringify(process.env.FLOOD_APP_GA4_ID),
'process.env.GTM_ID': JSON.stringify(process.env.FLOOD_APP_GTM_ID)
})
]
})