-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcraco.config.js
More file actions
59 lines (50 loc) · 1.5 KB
/
craco.config.js
File metadata and controls
59 lines (50 loc) · 1.5 KB
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
const path = require("path");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
const wasmExtensionRegExp = /\.wasm$/;
webpackConfig.resolve.extensions.push(".wasm");
webpackConfig.devtool = false;
webpackConfig.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((oneOf) => {
if (oneOf.loader && oneOf.loader.includes("file-loader")) {
oneOf.exclude.push(wasmExtensionRegExp);
}
});
}
});
const wasmLoader = {
test: /\.wasm$/,
type: "javascript/auto",
use: ["wasm-loader"],
};
webpackConfig.module.rules.push(wasmLoader);
webpackConfig.experiments = {
asyncWebAssembly: true,
};
webpackConfig.plugins.push(
new NodePolyfillPlugin({
excludeAliases: ["console"],
})
);
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
realm: path.resolve(__dirname, "shims/realm.js"),
"react-native-sqlite-storage": path.resolve(
__dirname,
"shims/react-native-sqlite-storage.js"
),
"jwt-decode": path.resolve(__dirname, "shims/jwt-decode.js"),
};
webpackConfig.module.rules.push({
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
});
return webpackConfig;
},
},
};