-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
executable file
·65 lines (62 loc) · 2.25 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
const path = require("path")
const webpack = require("webpack")
const { resolve } = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const CONFIG = {
// contains "development" || "production"
mode: process.env.NODE_ENV,
entry: "./index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
hashFunction: "xxhash64"
},
devtool:
process.env.NODE_ENV === "development" || process.env.REACT_APP_GIT_BRANCH === "dev"
? "eval-source-map"
: false,
plugins: [
new webpack.ProvidePlugin({ process: "process/browser" }),
new webpack.EnvironmentPlugin([
"REACT_APP_NAME",
"REACT_APP_AUTH0_DOMAIN",
"REACT_APP_AUTH0_CLIENT_ID_UI",
"REACT_APP_MAPBOX_STYLE",
"REACT_APP_MAPBOX_ACCESS_TOKEN",
"REACT_APP_MAP_SEQUENTIAL_SCALE",
"REACT_APP_MAP_DIVERGING_SCALE",
"REACT_APP_MAP_QUALITATIVE_SCALE"
]),
new HtmlWebpackPlugin({ title: process.env.REACT_APP_NAME })
],
module: {
rules: [
{
// Transpile ES6 to ES5 with babel
// Remove if your app does not use JSX or you don't need to support old browsers
test: /\.js$/,
loader: "babel-loader",
exclude: [/node_modules/],
options: {
presets: ["@babel/preset-react"]
}
}
]
},
resolve: {
alias: {
// From mapbox-gl-js README. Required for non-browserify bundlers (e.g. webpack):
"mapbox-gl$": resolve("./node_modules/mapbox-gl/dist/mapbox-gl.js")
}
},
use: {
loader: "babel-loader",
options: {
ignore: ["./node_modules/mapbox-gl/dist/mapbox-gl.js"]
}
}
}
// This line enables bundling against src in this repo rather than installed deck.gl module
module.exports = env => (env ? require("../../../webpack.config.local")(CONFIG)(env) : CONFIG)