@rsbuild/plugin-svgr 0.0.10 → 0.0.12
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/dist/index.js +19 -2
- package/package.json +12 -13
package/dist/index.js
CHANGED
|
@@ -33,12 +33,29 @@ __export(src_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(src_exports);
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
function getSvgoDefaultConfig() {
|
|
37
|
+
return {
|
|
38
|
+
plugins: [
|
|
39
|
+
{
|
|
40
|
+
name: "preset-default",
|
|
41
|
+
params: {
|
|
42
|
+
overrides: {
|
|
43
|
+
// viewBox is required to resize SVGs with CSS.
|
|
44
|
+
// @see https://github.com/svg/svgo/issues/1128
|
|
45
|
+
removeViewBox: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"prefixIds"
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
36
53
|
const pluginSvgr = (options = {}) => ({
|
|
37
54
|
name: "plugin-svgr",
|
|
38
55
|
setup(api) {
|
|
39
56
|
api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID }) => {
|
|
40
57
|
const config = api.getNormalizedConfig();
|
|
41
|
-
const { svgDefaultExport = "
|
|
58
|
+
const { svgDefaultExport = "url" } = options;
|
|
42
59
|
const assetType = "svg";
|
|
43
60
|
const distDir = (0, import_shared.getDistPath)(config.output, assetType);
|
|
44
61
|
const filename = (0, import_shared.getFilename)(config.output, assetType, isProd);
|
|
@@ -62,7 +79,7 @@ const pluginSvgr = (options = {}) => ({
|
|
|
62
79
|
});
|
|
63
80
|
rule.oneOf(CHAIN_ID.ONE_OF.SVG).type("javascript/auto").use(CHAIN_ID.USE.SVGR).loader(require.resolve("@svgr/webpack")).options({
|
|
64
81
|
svgo: true,
|
|
65
|
-
svgoConfig:
|
|
82
|
+
svgoConfig: getSvgoDefaultConfig()
|
|
66
83
|
}).end().when(
|
|
67
84
|
svgDefaultExport === "url",
|
|
68
85
|
(c) => c.use(CHAIN_ID.USE.URL).loader(require.resolve("url-loader")).options({
|
package/package.json
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svgr",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "svgr plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/web-infra-dev/rsbuild",
|
|
8
8
|
"directory": "packages/plugin-svgr"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
10
|
+
"license": "MIT",
|
|
12
11
|
"exports": {
|
|
13
12
|
".": {
|
|
14
13
|
"types": "./dist/index.d.ts",
|
|
15
14
|
"default": "./dist/index.js"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
18
19
|
"files": [
|
|
19
20
|
"dist"
|
|
20
21
|
],
|
|
21
|
-
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@svgr/webpack": "8.0.1",
|
|
24
24
|
"url-loader": "4.1.1",
|
|
25
|
-
"@rsbuild/shared": "0.0.
|
|
25
|
+
"@rsbuild/shared": "0.0.12"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^16",
|
|
29
|
-
"typescript": "^5",
|
|
30
|
-
"@rsbuild/core": "0.0.
|
|
31
|
-
"@rsbuild/test-helper": "0.0.
|
|
32
|
-
"@rsbuild/webpack": "0.0.9"
|
|
29
|
+
"typescript": "^5.2.2",
|
|
30
|
+
"@rsbuild/core": "0.0.12",
|
|
31
|
+
"@rsbuild/test-helper": "0.0.12"
|
|
33
32
|
},
|
|
34
33
|
"publishConfig": {
|
|
35
|
-
"registry": "https://registry.npmjs.org/",
|
|
36
34
|
"access": "public",
|
|
37
|
-
"provenance": true
|
|
35
|
+
"provenance": true,
|
|
36
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
37
|
},
|
|
39
38
|
"scripts": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"build": "modern build",
|
|
40
|
+
"dev": "modern build --watch"
|
|
42
41
|
}
|
|
43
42
|
}
|