-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-overrides.js
45 lines (37 loc) · 1022 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
33
34
35
36
37
38
39
40
41
42
43
44
45
const path = require('path')
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'
})
if (env === 'production') {
config.module.rules.push({
test: /\.worker\.js$/,
loader: "worker-loader",
options: {
filename: "[name].[contenthash].worker.js",
},
})
} else {
config.module.rules.push({
test: /\.worker\.js$/,
use: { loader: 'worker-loader' }
})
}
return config
}