-
Notifications
You must be signed in to change notification settings - Fork 14
/
config-overrides.js
61 lines (55 loc) · 1.72 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
/* eslint-disable */
const path = require('path');
const { override } = require('customize-cra');
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin');
const wasmExtensionRegExp = /\.wasm$/;
module.exports = override(
// make the file loader ignore wasm files
(config) => {
config.resolve.extensions.push('.wasm');
config.module.rules.find((rule) => {
return (rule.oneOf || []).find((item) => {
if (item.loader && item.loader.indexOf('file-loader') >= 0) {
item.exclude.push(wasmExtensionRegExp); //exclude wasm
return true; //ignore remaining rules
}
});
});
return config;
},
//hook up our helloHelper wasm module
(config) => {
config.plugins = (config.plugins || []).concat([
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, './onitamalib'),
outDir: path.resolve(__dirname, './src/onitamalib'),
extraArgs: '-- --features=web --features=agent',
}),
]);
return config;
},
(config) => {
config.resolve.alias.onitamalib = path.resolve(__dirname, 'src/onitamalib/index.js')
config.module.rules.forEach((rule) => {
(rule.oneOf || []).forEach((oneOf) => {
if (oneOf.type === 'asset/resource') {
oneOf.exclude.push(wasmExtensionRegExp);
}
})
})
config.experiments = {
syncWebAssembly: true,
topLevelAwait: true,
}
return config;
},
(config) => {
(config.optimization.minimizer || []).forEach((plugin) => {
if (plugin.constructor.name === 'TerserPlugin') {
plugin.options.minimizer.options.keep_fnames = true;
plugin.options.minimizer.options.keep_classnames = true;
}
});
return config;
},
);