-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
54 lines (50 loc) · 1.43 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
const path = require("path");
const { ProvidePlugin } = require("webpack");
module.exports = function override(config, env) {
const wasmExtensionRegExp = /\.wasm$/;
config.resolve.extensions.push(".wasm");
config.module.rules.forEach((rule) => {
(rule.oneOf || []).forEach((oneOf) => {
if (oneOf.loader && oneOf.loader.indexOf("file-loader") >= 0) {
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
config.module.rules.push({
test: wasmExtensionRegExp,
include: path.resolve(__dirname, "src"),
use: [{ loader: require.resolve("wasm-loader"), options: {} }],
});
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
},{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
});
config.plugins.push(
new ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser",
})
);
config.resolve.fallback = {
url: require.resolve("url/"),
assert: require.resolve("assert"),
crypto: require.resolve("crypto-browserify"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
stream: require.resolve("stream-browserify"),
zlib: require.resolve("browserify-zlib"),
};
config.ignoreWarnings= [/Failed to parse source map/],
config.optimization.splitChunks = {
chunks: "async",
minSize: 20000,
maxSize: 100000,
};
return config;
};