forked from vrm-c/vrm.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_webpack.ts
More file actions
36 lines (34 loc) · 808 Bytes
/
custom_webpack.ts
File metadata and controls
36 lines (34 loc) · 808 Bytes
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
import path from 'node:path';
export default function(context, options) {
return {
name: 'my-loaders',
configureWebpack(config, isServer) {
const rules = [];
for (const rule of config.module.rules) {
const copy = { ...rule };
if (rule.test.test('hoge.svg')) {
//
rules.push({
test: /\.svg$/,
type: 'asset/resource',
use: [
{
loader: path.resolve('custom_svg_loader.ts'),
options: {
/* ... */
},
},
],
});
}
else {
rules.push(copy);
}
}
return {
mergeStrategy: { 'module.rules': 'replace' },
module: { rules },
};
},
};
};