-
Notifications
You must be signed in to change notification settings - Fork 8
/
config-overrides.js
87 lines (80 loc) · 2 KB
/
config-overrides.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* eslint-disable react-hooks/rules-of-hooks */
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const { useBabelRc, override } = require('customize-cra');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer');
const polyFillOverride = function(config) {
config.plugins.push(
new NodePolyfillPlugin({
excludeAliases: [
"assert",
"buffer",
"console",
"constants",
"crypto",
"domain",
"events",
"os",
"path",
"punycode",
"querystring",
"stream",
"_stream_duplex",
"_stream_passthrough",
"_stream_transform",
"_stream_writable",
"string_decoder",
"sys",
"timers",
"tty",
"url",
"util",
"vm",
"zlib",
],
})
);
return config;
};
const ignoreWarnings = value => config => {
config.ignoreWarnings = value;
return config;
};
const copyWebpackOverride = function(config) {
config.plugins.push(
new CopyWebpackPlugin({ patterns: [
{from: 'node_modules/swagger-ui-dist', to: 'swagger'}
]})
);
return config;
};
const analyzer = function(config) {
if (config.mode === 'production') {
config = rewireWebpackBundleAnalyzer(config, config.mode, {
analyzerMode: 'static',
reportFilename: 'report.html'
})
}
return config
};
const namedChunks = function override(config, env) {
// Get rid of hash for js files
config.output.filename = "static/js/[name].js"
config.output.chunkFilename = "static/js/[name].chunk.js"
return config;
};
const watchOptions = (config) => {
config.watchOptions = {
ignored: ['**/**/*test.tsx', '**/test/**', '**/node_modules/**']
};
return config;
};
module.exports = override(
analyzer,
namedChunks,
polyFillOverride,
copyWebpackOverride,
useBabelRc(),
watchOptions,
ignoreWarnings([/Failed to parse source map/])
)