@itcase/config 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svgr/webpack.js +14 -6
package/package.json
CHANGED
package/svgr/webpack.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
2
|
+
|
|
1
3
|
const addSVGRtoWebpack = function (config) {
|
|
2
4
|
// Grab the existing rule that handles SVG imports
|
|
3
|
-
const fileLoaderRule = config.module.rules.find((rule) =>
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const fileLoaderRule = config.module.rules.find((rule) =>
|
|
6
|
+
rule.test?.test?.('.svg'),
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
// Add special processing rules for ".svg" files in code
|
|
6
10
|
config.module.rules.push(
|
|
7
11
|
// Reapply the existing rule, but only for svg imports ending in ?url
|
|
8
12
|
{
|
|
9
13
|
...fileLoaderRule,
|
|
10
|
-
resourceQuery: /url/, // *.svg?url
|
|
11
14
|
test: /\.svg$/i,
|
|
15
|
+
resourceQuery: /url/, // *.svg?url
|
|
12
16
|
},
|
|
13
17
|
// Convert all other *.svg imports to React components
|
|
14
18
|
{
|
|
15
|
-
issuer: fileLoaderRule.issuer,
|
|
16
|
-
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
|
|
17
19
|
test: /\.svg$/i,
|
|
20
|
+
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
|
|
21
|
+
issuer: fileLoaderRule.issuer,
|
|
18
22
|
use: ['@svgr/webpack'],
|
|
19
23
|
},
|
|
20
24
|
)
|
|
25
|
+
|
|
26
|
+
// Modify the file loader rule to ignore *.svg, since we have it handled now.
|
|
27
|
+
fileLoaderRule.exclude = /\.svg$/i
|
|
21
28
|
}
|
|
29
|
+
|
|
22
30
|
export { addSVGRtoWebpack }
|