@rsbuild/plugin-svgr 2.0.0-rc.4 → 2.0.1
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/assetLoader.d.ts +1 -0
- package/dist/assetLoader.mjs +3 -2
- package/package.json +5 -5
package/dist/assetLoader.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ type FilenameTemplate = string | ((resourcePath: string, resourceQuery?: string)
|
|
|
3
3
|
export type SvgAssetLoaderOptions = {
|
|
4
4
|
limit: number;
|
|
5
5
|
name: FilenameTemplate;
|
|
6
|
+
publicPath?: string | ((url: string, resourcePath: string, context: string) => string);
|
|
6
7
|
};
|
|
7
8
|
type RawLoaderDefinition<OptionsType = {}> = ((this: Rspack.LoaderContext<OptionsType>, content: Buffer) => string | Buffer | void | Promise<string | Buffer | void>) & {
|
|
8
9
|
raw: true;
|
package/dist/assetLoader.mjs
CHANGED
|
@@ -4,7 +4,7 @@ const SVG_MIME_TYPE = 'image/svg+xml';
|
|
|
4
4
|
const HASH_TEMPLATE_REGEX = /\[(?:[^:\]]+:)?(?:hash|contenthash)(?::[^\]]+)?]/i;
|
|
5
5
|
const normalizePath = (value)=>value.replace(/\\/g, '/');
|
|
6
6
|
const assetLoader = function(content) {
|
|
7
|
-
const { limit, name } = this.getOptions();
|
|
7
|
+
const { limit, name, publicPath } = this.getOptions();
|
|
8
8
|
if (content.length <= limit) {
|
|
9
9
|
const dataUrl = `data:${SVG_MIME_TYPE};base64,${content.toString('base64')}`;
|
|
10
10
|
return `export default ${JSON.stringify(dataUrl)}`;
|
|
@@ -18,7 +18,8 @@ const assetLoader = function(content) {
|
|
|
18
18
|
};
|
|
19
19
|
if ('string' == typeof name && HASH_TEMPLATE_REGEX.test(name)) assetInfo.immutable = true;
|
|
20
20
|
this.emitFile(filename, content, void 0, assetInfo);
|
|
21
|
-
|
|
21
|
+
const publicPathCode = 'function' == typeof publicPath ? JSON.stringify(publicPath(filename, this.resourcePath, this.rootContext)) : 'string' == typeof publicPath ? JSON.stringify(`${publicPath.endsWith('/') ? publicPath : `${publicPath}/`}${filename}`) : `__webpack_public_path__ + ${JSON.stringify(filename)}`;
|
|
22
|
+
return `export default ${publicPathCode};`;
|
|
22
23
|
};
|
|
23
24
|
assetLoader.raw = true;
|
|
24
25
|
const src_assetLoader = assetLoader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svgr",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "SVGR plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@rsbuild/plugin-react": "^2.0.0
|
|
23
|
+
"@rsbuild/plugin-react": "^2.0.0",
|
|
24
24
|
"@svgr/core": "8.1.0",
|
|
25
25
|
"@svgr/plugin-jsx": "8.1.0",
|
|
26
26
|
"@svgr/plugin-svgo": "8.1.0",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.5",
|
|
32
|
-
"@rslib/core": "0.21.
|
|
32
|
+
"@rslib/core": "0.21.2",
|
|
33
33
|
"@types/node": "^24.12.2",
|
|
34
34
|
"svgo": "^3.3.3",
|
|
35
|
-
"typescript": "^6.0.
|
|
36
|
-
"@rsbuild/core": "2.0.0
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"@rsbuild/core": "2.0.0",
|
|
37
37
|
"@scripts/test-helper": "1.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|