-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
54 lines (46 loc) · 1.34 KB
/
webpack.config.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
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
module.exports = async (env, argv) => {
const config = await createExpoWebpackConfigAsync(
{
...env,
babel: {
dangerouslyAddModulePathsToTranspile: ['dooboo-ui', '@dooboo-ui'],
},
},
argv,
);
// Remove existing rules about SVG and inject our own
// (Inspired by https://github.com/storybookjs/storybook/issues/6758#issuecomment-495598635)
config.module.rules = config.module.rules.map((rule) => {
if (rule.oneOf) {
let hasModified = false;
const newRule = {
...rule,
oneOf: rule.oneOf.map((oneOfRule) => {
if (oneOfRule.test && oneOfRule.test.toString().includes('svg')) {
hasModified = true;
const test = oneOfRule.test.toString().replace('|svg', '');
return {...oneOfRule, test: new RegExp(test)};
} else return oneOfRule;
}),
};
// Add new rule to use svgr
if (hasModified) {
newRule.oneOf.unshift({
test: /\.svg$/,
exclude: /node_modules/,
use: [
{
loader: '@svgr/webpack',
options: {
viewBox: true,
},
},
],
});
}
return newRule;
} else return rule;
});
return config;
};