-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
32 lines (27 loc) · 1007 Bytes
/
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
const path = require('path');
module.exports = function override (config, env) {
const wasmExtensionRegExp = /\.wasm$/;
const workerRegExp = /\.worker\.js$/;
config.resolve.extensions.push('.wasm');
config.module.rules.forEach(rule => {
(rule.oneOf || []).forEach(oneOf => {
if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) {
// Make file-loader ignore WASM files
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
// Add a dedicated loader for WASM
config.module.rules.push({
test: wasmExtensionRegExp,
include: path.resolve(__dirname, 'src'),
use: [{ loader: require.resolve('wasm-loader'), options: {} }]
});
// Add a dedicated loader for WASM
config.module.rules.push({
test: workerRegExp,
include: path.resolve(__dirname, 'src'),
use: [{ loader: require.resolve('worker-loader'), options: {} }]
});
return config;
};