-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
45 lines (39 loc) · 1.13 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
const path = require('path')
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin')
module.exports = function override(config, env) {
config.resolve.extensions.push('.wasm')
config.module.rules = [
...config.module.rules.map((rule) => {
if (!rule.oneOf) {
return rule
}
rule.oneOf = [
...rule.oneOf.slice(0, -1),
{
test: /\.(glsl|frag|vert)$/,
exclude: [/node_modules/],
use: ['raw-loader', 'glslify-loader'],
},
...rule.oneOf.slice(-1),
]
return rule
}),
]
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(/\.wasm$/)
oneOf.exclude.push(/\.(glsl|frag|vert)$/)
}
})
})
config.plugins = (config.plugins || []).concat([
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, './src/cargo'),
extraArgs: '--no-typescript',
outDir: path.resolve(__dirname, './src/cargo/build'),
}),
])
return config
}