forked from SINTEF-9012/madt-neodash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
58 lines (56 loc) · 1.59 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
const path = require('path');
const webpack = require('webpack');
const rules = [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
options: { presets: ['@babel/env'] },
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/,
exclude: /(node_modules\/react-leaflet-heatmap-layer-v3)/,
enforce: 'pre',
use: ['source-map-loader'],
},
{
test: /.(png|svg|jpe?g|gif|woff2?|ttf|eot)$/,
use: ['file-loader'],
},
];
// TODO - move this config to a dedicated environment file.
// TODO - use process.env.NODE_ENV which will directly return the environment string "development", "production".
module.exports = (env) => {
const production = env.production;
return {
entry: './src/index.tsx',
mode: production ? 'production' : 'development',
devtool: production ? undefined : 'source-map',
module: {
rules: rules,
},
resolve: {
extensions: ['*', '.js', '.jsx', '.ts', '.tsx'],
fallback: {"fs": false,
"https": require.resolve("https-browserify"),
"crypto": require.resolve("crypto-browserify"),
"path": require.resolve("path-browserify"),
"timers": require.resolve("timers-browserify"),
"http": require.resolve("stream-http")
}
},
output: {
filename: 'bundle.js',
},
devServer: {
port: 3000,
hot: true,
},
plugins: production ? [] : [new webpack.HotModuleReplacementPlugin()],
ignoreWarnings: [/Failed to parse source map/],
};
};