rspack-plugin-svg-sprite 1.5.2 → 1.5.3
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/CHANGELOG.md +55 -0
- package/README.md +74 -12
- package/dist/loader.d.ts +31 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +160 -9
- package/dist/loader.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +28 -31
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# rspack-plugin-svg-sprite
|
|
2
|
+
|
|
3
|
+
## 1.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6](https://github.com/yichenzhu1337/rspack-plugin-svg-sprite/pull/6) [`ef734ce`](https://github.com/yichenzhu1337/rspack-plugin-svg-sprite/commit/ef734ce1bed584b1fa82a56a895511fc8240a2b0) Thanks [@yichenzhu1337](https://github.com/yichenzhu1337)! - Fix icons disappearing from the extracted sprite, and parse the root `<svg>` tag correctly.
|
|
8
|
+
- **Extract mode no longer loses icons in watch mode or after a cached restart.** Before, editing one icon removed every other icon from `sprite.svg`, editing a JS file emitted no sprite at all, and a second build with a persistent cache (webpack `cache.type: 'filesystem'`, Rspack `experiments.cache` or `cache.type: 'persistent'`) emitted no sprite. Extract-mode modules now always re-run so every icon reaches the sprite. Inline mode is unchanged. Large icon sets rebuild slightly slower in development (about 0.1 ms per icon).
|
|
9
|
+
- **The root `<svg>` tag is read as XML.** Attributes that 1.5.2 mangled now come through intact: `preserveAspectRatio` keeps its case (browsers ignored the lowercased name, so icons with it may now scale as the attribute says; remove the attribute to get the old look), values containing `'`, `"` or `>` are kept whole, `viewBox = "…"` with spaces is recognised, and an `<svg` inside a leading comment is skipped. Tags the new parser cannot read fall back to the previous behavior.
|
|
10
|
+
- **A warning when an asset rule captures your SVG.** If another rule turns the file into an `asset` module, the build now warns with the file name and the fix (`type: 'javascript/auto'`). The build result is unchanged.
|
|
11
|
+
- **Stable sprite order.** Symbols in each extracted sprite are sorted by id, so identical builds produce identical files.
|
|
12
|
+
|
|
13
|
+
Output for every icon that 1.5.2 already handled correctly is byte-for-byte unchanged.
|
|
14
|
+
|
|
15
|
+
## 1.5.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- abdc666: Support named ESM import of SvgSpritePlugin ([#1](https://github.com/yichenzhu1337/rspack-plugin-svg-sprite/pull/1))
|
|
20
|
+
|
|
21
|
+
## 1.5.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 331d1da: Restore xmlns:xlink namespace and defs wrapper in generated sprites
|
|
26
|
+
|
|
27
|
+
## 1.5.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- e4fada7: Auto-read publicPath from compiler output config in extract mode
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 70c7262: Derive viewBox from width/height when viewBox attribute is missing
|
|
36
|
+
- 88abb4e: Harden SVG parsing, Rsbuild rule filtering, and publicPath normalization
|
|
37
|
+
- 479ed71: Implement plainSprite option that was accepted but never used
|
|
38
|
+
- d98b90e: Prevent memory leak in SSR by skipping symbol registration without document
|
|
39
|
+
- 1ea05c4: Fix querySelector crash on special chars, watch mode ghost symbols, and FallbackRawSource byte count
|
|
40
|
+
- d440f3d: Rsbuild plugin removes conflicting SVG rules, adds include/exclude support
|
|
41
|
+
- b71a8cf: Warn when duplicate symbol IDs come from different files
|
|
42
|
+
|
|
43
|
+
## 1.4.0
|
|
44
|
+
|
|
45
|
+
### Minor Changes
|
|
46
|
+
|
|
47
|
+
- bf0738a: Add Rsbuild plugin, ship TS declarations, SEO and discoverability overhaul
|
|
48
|
+
|
|
49
|
+
## 1.3.0
|
|
50
|
+
|
|
51
|
+
### Minor Changes
|
|
52
|
+
|
|
53
|
+
- 87f7009: Warn on silent misconfiguration, document type: javascript/auto
|
|
54
|
+
|
|
55
|
+
Versions before 1.3.0 (1.1.1, 1.2.0) were published without release notes; see [npm](https://www.npmjs.com/package/rspack-plugin-svg-sprite?activeTab=versions).
|
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# rspack-plugin-svg-sprite
|
|
2
2
|
|
|
3
|
-
> SVG sprite loader and plugin for Rspack — a drop-in replacement for [`svg-sprite-loader`](https://github.com/JetBrains/svg-sprite-loader)
|
|
3
|
+
> SVG sprite loader and plugin for [Rspack](https://rspack.dev/) and [Rsbuild](https://rsbuild.dev/) — a drop-in replacement for [`svg-sprite-loader`](https://github.com/JetBrains/svg-sprite-loader), which doesn't work with Rspack.
|
|
4
4
|
|
|
5
|
+
[](https://npmx.dev/package/rspack-plugin-svg-sprite)
|
|
6
|
+
[](https://npmx.dev/package/rspack-plugin-svg-sprite)
|
|
5
7
|
[](https://github.com/yichenzhu1337/rspack-plugin-svg-sprite/actions/workflows/ci.yml)
|
|
6
|
-
[](https://bundlephobia.com/package/rspack-plugin-svg-sprite)
|
|
8
|
+
[](https://codecov.io/gh/yichenzhu1337/rspack-plugin-svg-sprite)
|
|
9
|
+
[](https://npmx.dev/package/rspack-plugin-svg-sprite)
|
|
10
|
+
[](https://npmx.dev/package/rspack-plugin-svg-sprite)
|
|
11
|
+
[](https://github.com/yichenzhu1337/rspack-plugin-svg-sprite/blob/main/LICENSE)
|
|
11
12
|
|
|
12
13
|
**[Live Demo](https://yichenzhu1337.github.io/rspack-plugin-svg-sprite/)** | **[npm](https://www.npmjs.com/package/rspack-plugin-svg-sprite)** | **[npmcharts](https://npmcharts.com/compare/rspack-plugin-svg-sprite?minimal=true)**
|
|
13
14
|
|
|
@@ -15,6 +16,8 @@
|
|
|
15
16
|
npm install rspack-plugin-svg-sprite -D
|
|
16
17
|
```
|
|
17
18
|
|
|
19
|
+
**Coming from `svg-sprite-loader`?** Swap the loader path and the plugin import; your component code stays the same. [See the diff ↓](#migrating-from-svg-sprite-loader)
|
|
20
|
+
|
|
18
21
|
---
|
|
19
22
|
|
|
20
23
|
## Why SVG sprites?
|
|
@@ -179,8 +182,8 @@ import icon from './icon.svg';
|
|
|
179
182
|
| `extract` | `boolean` | `false` | Enable extract mode to emit an external sprite file instead of inlining. |
|
|
180
183
|
| `spriteFilename` | `string` | `'sprite.svg'` | Output filename for the extracted sprite (extract mode only). |
|
|
181
184
|
| `publicPath` | `string` | `''` | Public URL prefix for the sprite file (extract mode only). Auto-detected from `output.publicPath` if not set. |
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
|
|
186
|
+
`include` and `exclude` are not loader options. To limit which SVGs become sprite symbols, use the `include` / `exclude` conditions of the bundler rule itself, or the options of the same name on the Rsbuild plugin (`pluginSvgSprite({ include: /icons/ })`).
|
|
184
187
|
|
|
185
188
|
### Plugin Options (Extract Mode)
|
|
186
189
|
|
|
@@ -388,10 +391,13 @@ Looking for the right SVG solution for Rspack? Here's how the options compare:
|
|
|
388
391
|
|
|
389
392
|
## Compatibility
|
|
390
393
|
|
|
391
|
-
| Bundler |
|
|
392
|
-
| ---------------------------------- |
|
|
393
|
-
| [Rspack](https://rspack.dev/) |
|
|
394
|
-
| [
|
|
394
|
+
| Bundler | Tested versions | What the test suite covers |
|
|
395
|
+
| ---------------------------------- | --------------- | ---------------------------------------------------------------- |
|
|
396
|
+
| [Rspack](https://rspack.dev/) | 1.7 and 2.3 | Inline and extract builds, watch mode, persistent cache restarts |
|
|
397
|
+
| [Rsbuild](https://rsbuild.dev/) | 1.7 and 2.3 | The `pluginSvgSprite` wrapper |
|
|
398
|
+
| [Webpack](https://webpack.js.org/) | 5.105 | Inline and extract builds, watch mode, filesystem cache restarts |
|
|
399
|
+
|
|
400
|
+
The peer range still accepts `@rspack/core` 0.5 and newer, so existing installs keep working, but versions older than 1.7 are not exercised by the tests.
|
|
395
401
|
|
|
396
402
|
## Examples
|
|
397
403
|
|
|
@@ -452,6 +458,62 @@ module.exports = {
|
|
|
452
458
|
};
|
|
453
459
|
```
|
|
454
460
|
|
|
461
|
+
### Icon is a broken image, or DevTools shows `data:image/svg+xml;base64`
|
|
462
|
+
|
|
463
|
+
**Symptom:** The build succeeds, but the icon does not render and its source is a `data:` URI or a hashed `.svg` file that contains JavaScript.
|
|
464
|
+
|
|
465
|
+
**Cause:** Another rule (your own image rule, or a framework default) assigns an asset module type to `.svg` files. The sprite loader still runs, but its JavaScript output is emitted as the image instead of being executed.
|
|
466
|
+
|
|
467
|
+
**Fix:** The loader prints a build warning that names the file and the module type, for example `... is handled as module type "asset/inline"`. Add `type: 'javascript/auto'` to the rule that uses `rspack-plugin-svg-sprite/loader`, or exclude your icon folder from the other rule.
|
|
468
|
+
|
|
469
|
+
### Icons vanish from the extracted sprite during development, or after a cached rebuild
|
|
470
|
+
|
|
471
|
+
**Symptom:** In extract mode, icons disappear from `sprite.svg` after you edit a file while the dev server is running. Or, with a persistent build cache (`cache.type: 'persistent'` in Rspack 2, `experiments.cache` in Rspack 1, `cache.type: 'filesystem'` in webpack), the second build emits no sprite at all.
|
|
472
|
+
|
|
473
|
+
**Cause:** Versions up to 1.5.2 let the bundler cache SVG modules in extract mode. A cached module skips the loader, so its symbol was never registered with the plugin.
|
|
474
|
+
|
|
475
|
+
**Fix:** Upgrade to 1.5.3 or newer. In extract mode the loader now opts out of caching, so every icon is read again on each rebuild (roughly 0.05 to 0.1 ms per icon). Inline mode is unaffected and stays cached.
|
|
476
|
+
|
|
477
|
+
### Two icons show the same gradient, clip path, or class styling
|
|
478
|
+
|
|
479
|
+
**Cause:** All symbols live in one SVG document. Icons minified by SVGO often reuse ids such as `id="a"`, and Illustrator exports reuse class names such as `.cls-1`. The first definition in the document wins.
|
|
480
|
+
|
|
481
|
+
**Fix:** Let SVGO prefix ids and class names per file before the sprite loader runs:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
npm install svgo svgo-loader -D
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
{
|
|
489
|
+
test: /\.svg$/,
|
|
490
|
+
type: 'javascript/auto',
|
|
491
|
+
use: [
|
|
492
|
+
{ loader: 'rspack-plugin-svg-sprite/loader', options: { symbolId: 'icon-[name]' } },
|
|
493
|
+
{ loader: 'svgo-loader', options: { plugins: [{ name: 'prefixIds' }] } },
|
|
494
|
+
],
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Loaders run from the last entry to the first, so SVGO processes the raw SVG and the sprite loader receives the result. This recipe is covered by the test suite with svgo-loader 5 and svgo 4.
|
|
499
|
+
|
|
500
|
+
### An icon is scaled differently after upgrading from 1.5.2 or older
|
|
501
|
+
|
|
502
|
+
**Cause:** Older versions lowercased attribute names on the root `<svg>`, which turned `preserveAspectRatio` into an attribute browsers ignore. The attribute is now kept exactly as written, so the icon scales the way the SVG file asks.
|
|
503
|
+
|
|
504
|
+
**Fix:** If you preferred the old rendering, remove `preserveAspectRatio` from the source SVG.
|
|
505
|
+
|
|
506
|
+
### One plugin instance shared by several configs
|
|
507
|
+
|
|
508
|
+
If you export an array of configs (a multi-compiler build, for example client and server), create a separate `new SvgSpritePlugin()` for each config. A shared instance puts the icons of every build into each sprite.
|
|
509
|
+
|
|
510
|
+
### Known limitations
|
|
511
|
+
|
|
512
|
+
- An SVG with no `viewBox` and no numeric `width` and `height` gets `viewBox="0 0 24 24"`. Add a `viewBox` to the source file if that is not its real size.
|
|
513
|
+
- `spriteFilename` is used literally. Placeholders such as `[hash]` or `[chunkname]` are not interpolated.
|
|
514
|
+
- The sprite URL is fixed at build time from the loader's `publicPath` option, or from `output.publicPath` when that is a plain string. `output.publicPath: 'auto'` and function values are not read, so set the loader's `publicPath` in those setups.
|
|
515
|
+
- The Rsbuild plugin replaces Rsbuild's built-in SVG rule. `./icon.svg?url`, `?inline` and `?raw` therefore also return a sprite symbol, and SVGs outside the plugin's `include` / `exclude` scope are left without Rsbuild's default handling.
|
|
516
|
+
|
|
455
517
|
## Contributing
|
|
456
518
|
|
|
457
519
|
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, project structure, and guidelines.
|
package/dist/loader.d.ts
CHANGED
|
@@ -10,12 +10,43 @@ interface LoaderContext {
|
|
|
10
10
|
cacheable?: (flag?: boolean) => void;
|
|
11
11
|
resourcePath: string;
|
|
12
12
|
getOptions?: () => LoaderOptions;
|
|
13
|
+
emitWarning?: (warning: Error) => void;
|
|
13
14
|
_compilation?: any;
|
|
14
15
|
_compiler?: any;
|
|
16
|
+
_module?: any;
|
|
15
17
|
}
|
|
18
|
+
declare function legacyParseViewBox(svgContent: string): string;
|
|
19
|
+
declare function legacyExtractSvgInner(svgContent: string): string;
|
|
20
|
+
declare function legacyExtractSvgAttrs(svgContent: string): Record<string, string>;
|
|
21
|
+
interface RootTag {
|
|
22
|
+
/** Root attributes in source order, names and values exactly as written. */
|
|
23
|
+
attrs: Array<[string, string]>;
|
|
24
|
+
/** Index of the first character after the root open tag. */
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parses the root `<svg ...>` open tag as XML: quoted values may contain `>` and the other
|
|
29
|
+
* quote character, attribute names keep their case, and `<svg` text inside a comment that
|
|
30
|
+
* precedes the root is skipped.
|
|
31
|
+
*
|
|
32
|
+
* Returns null whenever the tag is not well-formed XML. Callers then run the v1 regex code
|
|
33
|
+
* unchanged, so malformed input behaves exactly as it did before.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseRootTag(svgContent: string): RootTag | null;
|
|
16
36
|
export declare function parseViewBox(svgContent: string): string;
|
|
17
37
|
export declare function extractSvgInner(svgContent: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Root attributes with lowercased names. The lowercasing is the v1 contract of this exported
|
|
40
|
+
* helper and is kept for backwards compatibility. The loader itself uses the case-preserving
|
|
41
|
+
* variant so attributes such as `preserveAspectRatio` survive into the symbol.
|
|
42
|
+
*/
|
|
18
43
|
export declare function extractSvgAttrs(svgContent: string): Record<string, string>;
|
|
44
|
+
/** @internal v1 regex helpers, kept verbatim as the fallback for malformed root tags. */
|
|
45
|
+
export declare const legacy: {
|
|
46
|
+
parseViewBox: typeof legacyParseViewBox;
|
|
47
|
+
extractSvgInner: typeof legacyExtractSvgInner;
|
|
48
|
+
extractSvgAttrs: typeof legacyExtractSvgAttrs;
|
|
49
|
+
};
|
|
19
50
|
export declare function generateSymbolId(resourcePath: string, options: LoaderOptions): string;
|
|
20
51
|
declare function svgSpriteLoader(this: LoaderContext, content: string): string;
|
|
21
52
|
declare const loader: typeof svgSpriteLoader & {
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,6BAA6B,CAAC;AAEpD,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,aAAa,CAAC;IACjC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,6BAA6B,CAAC;AAEpD,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAA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,MAAM,CAAC,CAE1E;AAED,yFAAyF;AACzF,eAAO,MAAM,MAAM;;;;CAIlB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAerF;AAmBD,iBAAS,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAmHrE;AAED,QAAA,MAAM,MAAM;;CAAgD,CAAC;AAC7D,eAAe,MAAM,CAAC"}
|
package/dist/loader.js
CHANGED
|
@@ -33,14 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.NAMESPACE = void 0;
|
|
36
|
+
exports.legacy = exports.NAMESPACE = void 0;
|
|
37
|
+
exports.parseRootTag = parseRootTag;
|
|
37
38
|
exports.parseViewBox = parseViewBox;
|
|
38
39
|
exports.extractSvgInner = extractSvgInner;
|
|
39
40
|
exports.extractSvgAttrs = extractSvgAttrs;
|
|
40
41
|
exports.generateSymbolId = generateSymbolId;
|
|
41
42
|
const path = __importStar(require("path"));
|
|
42
43
|
exports.NAMESPACE = 'rspack-plugin-svg-sprite';
|
|
43
|
-
function
|
|
44
|
+
function legacyParseViewBox(svgContent) {
|
|
44
45
|
// Extract the root <svg> opening tag to avoid matching attributes on child elements
|
|
45
46
|
const svgTagMatch = svgContent.match(/<svg([^>]*)>/i);
|
|
46
47
|
const svgTag = svgTagMatch ? svgTagMatch[1] : '';
|
|
@@ -55,11 +56,11 @@ function parseViewBox(svgContent) {
|
|
|
55
56
|
}
|
|
56
57
|
return '0 0 24 24';
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function legacyExtractSvgInner(svgContent) {
|
|
59
60
|
const innerMatch = svgContent.match(/<svg[^>]*>([\s\S]*)<\/svg>/i);
|
|
60
61
|
return innerMatch ? innerMatch[1].trim() : svgContent;
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
+
function legacyExtractSvgAttrs(svgContent) {
|
|
63
64
|
const attrs = {};
|
|
64
65
|
const svgTagMatch = svgContent.match(/<svg([^>]*)>/i);
|
|
65
66
|
if (!svgTagMatch)
|
|
@@ -80,6 +81,135 @@ function extractSvgAttrs(svgContent) {
|
|
|
80
81
|
}
|
|
81
82
|
return attrs;
|
|
82
83
|
}
|
|
84
|
+
function isXmlSpace(ch) {
|
|
85
|
+
return ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parses the root `<svg ...>` open tag as XML: quoted values may contain `>` and the other
|
|
89
|
+
* quote character, attribute names keep their case, and `<svg` text inside a comment that
|
|
90
|
+
* precedes the root is skipped.
|
|
91
|
+
*
|
|
92
|
+
* Returns null whenever the tag is not well-formed XML. Callers then run the v1 regex code
|
|
93
|
+
* unchanged, so malformed input behaves exactly as it did before.
|
|
94
|
+
*/
|
|
95
|
+
function parseRootTag(svgContent) {
|
|
96
|
+
const opener = /<!--|<svg/gi;
|
|
97
|
+
let start = -1;
|
|
98
|
+
let match;
|
|
99
|
+
while ((match = opener.exec(svgContent)) !== null) {
|
|
100
|
+
if (match[0] === '<!--') {
|
|
101
|
+
const close = svgContent.indexOf('-->', match.index + 4);
|
|
102
|
+
if (close !== -1)
|
|
103
|
+
opener.lastIndex = close + 3;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
start = match.index + 4;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (start === -1)
|
|
110
|
+
return null;
|
|
111
|
+
const attrs = [];
|
|
112
|
+
const n = svgContent.length;
|
|
113
|
+
let i = start;
|
|
114
|
+
for (;;) {
|
|
115
|
+
const wsStart = i;
|
|
116
|
+
while (i < n && isXmlSpace(svgContent[i]))
|
|
117
|
+
i++;
|
|
118
|
+
if (i >= n)
|
|
119
|
+
return null;
|
|
120
|
+
if (svgContent[i] === '>')
|
|
121
|
+
return { attrs, end: i + 1 };
|
|
122
|
+
if (i === wsStart)
|
|
123
|
+
return null;
|
|
124
|
+
const nameStart = i;
|
|
125
|
+
while (i < n && !isXmlSpace(svgContent[i]) && '=<>"\'/'.indexOf(svgContent[i]) === -1)
|
|
126
|
+
i++;
|
|
127
|
+
if (i === nameStart)
|
|
128
|
+
return null;
|
|
129
|
+
const name = svgContent.slice(nameStart, i);
|
|
130
|
+
while (i < n && isXmlSpace(svgContent[i]))
|
|
131
|
+
i++;
|
|
132
|
+
if (svgContent[i] !== '=')
|
|
133
|
+
return null;
|
|
134
|
+
i++;
|
|
135
|
+
while (i < n && isXmlSpace(svgContent[i]))
|
|
136
|
+
i++;
|
|
137
|
+
const quote = svgContent[i];
|
|
138
|
+
if (quote !== '"' && quote !== "'")
|
|
139
|
+
return null;
|
|
140
|
+
const close = svgContent.indexOf(quote, i + 1);
|
|
141
|
+
if (close === -1)
|
|
142
|
+
return null;
|
|
143
|
+
attrs.push([name, svgContent.slice(i + 1, close)]);
|
|
144
|
+
i = close + 1;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function firstAttr(root, name) {
|
|
148
|
+
for (const [attrName, value] of root.attrs) {
|
|
149
|
+
if (attrName === name)
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
const DIMENSION = /^(\d+(?:\.\d+)?)(?:px)?$/;
|
|
155
|
+
function parseViewBox(svgContent) {
|
|
156
|
+
const root = parseRootTag(svgContent);
|
|
157
|
+
if (!root)
|
|
158
|
+
return legacyParseViewBox(svgContent);
|
|
159
|
+
const viewBox = firstAttr(root, 'viewBox');
|
|
160
|
+
if (viewBox)
|
|
161
|
+
return viewBox;
|
|
162
|
+
const widthMatch = DIMENSION.exec(firstAttr(root, 'width') || '');
|
|
163
|
+
const heightMatch = DIMENSION.exec(firstAttr(root, 'height') || '');
|
|
164
|
+
if (widthMatch && heightMatch) {
|
|
165
|
+
return '0 0 ' + widthMatch[1] + ' ' + heightMatch[1];
|
|
166
|
+
}
|
|
167
|
+
return '0 0 24 24';
|
|
168
|
+
}
|
|
169
|
+
function extractSvgInner(svgContent) {
|
|
170
|
+
const root = parseRootTag(svgContent);
|
|
171
|
+
if (root) {
|
|
172
|
+
const closer = /<\/svg\s*>/gi;
|
|
173
|
+
closer.lastIndex = root.end;
|
|
174
|
+
let last = -1;
|
|
175
|
+
let match;
|
|
176
|
+
while ((match = closer.exec(svgContent)) !== null)
|
|
177
|
+
last = match.index;
|
|
178
|
+
if (last !== -1)
|
|
179
|
+
return svgContent.slice(root.end, last).trim();
|
|
180
|
+
}
|
|
181
|
+
return legacyExtractSvgInner(svgContent);
|
|
182
|
+
}
|
|
183
|
+
function readSvgAttrs(svgContent, preserveCase) {
|
|
184
|
+
const root = parseRootTag(svgContent);
|
|
185
|
+
if (!root)
|
|
186
|
+
return legacyExtractSvgAttrs(svgContent);
|
|
187
|
+
const attrs = {};
|
|
188
|
+
for (const [name, value] of root.attrs) {
|
|
189
|
+
// Skip namespaced attributes (xml:space, xmlns:xlink) and known non-visual attrs
|
|
190
|
+
if (name.includes(':'))
|
|
191
|
+
continue;
|
|
192
|
+
const lower = name.toLowerCase();
|
|
193
|
+
if (lower !== 'xmlns' && lower !== 'version' && lower !== 'class' && lower !== 'style') {
|
|
194
|
+
attrs[preserveCase ? name : lower] = value;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return attrs;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Root attributes with lowercased names. The lowercasing is the v1 contract of this exported
|
|
201
|
+
* helper and is kept for backwards compatibility. The loader itself uses the case-preserving
|
|
202
|
+
* variant so attributes such as `preserveAspectRatio` survive into the symbol.
|
|
203
|
+
*/
|
|
204
|
+
function extractSvgAttrs(svgContent) {
|
|
205
|
+
return readSvgAttrs(svgContent, false);
|
|
206
|
+
}
|
|
207
|
+
/** @internal v1 regex helpers, kept verbatim as the fallback for malformed root tags. */
|
|
208
|
+
exports.legacy = {
|
|
209
|
+
parseViewBox: legacyParseViewBox,
|
|
210
|
+
extractSvgInner: legacyExtractSvgInner,
|
|
211
|
+
extractSvgAttrs: legacyExtractSvgAttrs,
|
|
212
|
+
};
|
|
83
213
|
function generateSymbolId(resourcePath, options) {
|
|
84
214
|
if (typeof options.symbolId === 'function') {
|
|
85
215
|
return options.symbolId(resourcePath);
|
|
@@ -109,24 +239,45 @@ function interopRequire(varName, modulePath) {
|
|
|
109
239
|
';\n');
|
|
110
240
|
}
|
|
111
241
|
function svgSpriteLoader(content) {
|
|
242
|
+
const options = this.getOptions ? this.getOptions() : {};
|
|
112
243
|
if (this.cacheable) {
|
|
113
|
-
|
|
244
|
+
// Extract mode registers the symbol with SvgSpritePlugin as a side effect of running the
|
|
245
|
+
// loader. A cached module skips the loader, so the symbol would be missing from the sprite
|
|
246
|
+
// on incremental rebuilds and after a persistent-cache restart. Inline mode keeps caching.
|
|
247
|
+
if (options.extract) {
|
|
248
|
+
this.cacheable(false);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
this.cacheable();
|
|
252
|
+
}
|
|
114
253
|
}
|
|
115
254
|
if (!content.includes('<svg')) {
|
|
116
255
|
throw new Error('rspack-plugin-svg-sprite: Invalid SVG content in ' + this.resourcePath);
|
|
117
256
|
}
|
|
118
|
-
const
|
|
257
|
+
const moduleType = this._module && this._module.type;
|
|
258
|
+
if (typeof moduleType === 'string' && moduleType.indexOf('asset') === 0 && this.emitWarning) {
|
|
259
|
+
this.emitWarning(new Error('[rspack-plugin-svg-sprite] ' +
|
|
260
|
+
this.resourcePath +
|
|
261
|
+
' is handled as module type "' +
|
|
262
|
+
moduleType +
|
|
263
|
+
'", so the sprite loader output is emitted as a file or data URI instead of being' +
|
|
264
|
+
' executed, and the icon will not render.\n' +
|
|
265
|
+
'Another rule assigns an asset type to .svg files. Add `type: "javascript/auto"` to' +
|
|
266
|
+
' the rule that uses rspack-plugin-svg-sprite/loader, or exclude these files from' +
|
|
267
|
+
' the other rule.'));
|
|
268
|
+
}
|
|
119
269
|
const resourcePath = this.resourcePath;
|
|
120
270
|
const symbolId = generateSymbolId(resourcePath, options);
|
|
121
271
|
const viewBox = parseViewBox(content);
|
|
122
272
|
const innerContent = extractSvgInner(content);
|
|
123
|
-
const svgAttrs =
|
|
273
|
+
const svgAttrs = readSvgAttrs(content, true);
|
|
124
274
|
const extract = options.extract || false;
|
|
125
275
|
const esModule = options.esModule !== undefined ? options.esModule : true;
|
|
126
276
|
let attrString = 'id="' + symbolId + '" viewBox="' + viewBox + '"';
|
|
127
277
|
Object.keys(svgAttrs).forEach((key) => {
|
|
128
|
-
|
|
129
|
-
|
|
278
|
+
const lower = key.toLowerCase();
|
|
279
|
+
if (lower !== 'viewbox' && lower !== 'id' && lower !== 'width' && lower !== 'height') {
|
|
280
|
+
attrString += ' ' + key + '="' + svgAttrs[key].replace(/"/g, '"') + '"';
|
|
130
281
|
}
|
|
131
282
|
});
|
|
132
283
|
const symbolContent = '<symbol ' + attrString + '>' + innerContent + '</symbol>';
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,oCAgBC;AAED,0CAGC;AAED,0CAmBC;AAED,4CAeC;AA/ED,2CAA6B;AAEhB,QAAA,SAAS,GAAG,0BAA0B,CAAC;AAkBpD,SAAgB,YAAY,CAAC,UAAkB;IAC7C,oFAAoF;IACpF,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACvD,IA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 -49,7 +49,12 @@ class SvgSpritePlugin {
|
|
|
49
49
|
symbolsByFile[filename].push(sym);
|
|
50
50
|
});
|
|
51
51
|
Object.keys(symbolsByFile).forEach((filename) => {
|
|
52
|
-
|
|
52
|
+
// Loaders finish in a different order on every build. Sort so identical input
|
|
53
|
+
// always produces an identical sprite file.
|
|
54
|
+
const ordered = symbolsByFile[filename]
|
|
55
|
+
.slice()
|
|
56
|
+
.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
57
|
+
const content = this.generateSprite(ordered);
|
|
53
58
|
const RawSource = resolveRawSource(compiler);
|
|
54
59
|
compilation.emitAsset(filename, new RawSource(content));
|
|
55
60
|
});
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;AAuKA,8CAOC;AAED,4CASC;AAvLD,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAe7C,MAAM,aAAa,GAA2B;IAC5C,WAAW,EAAE,KAAK;IAClB,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF,SAAS,KAAK,CAAC,MAA8B,EAAE,MAAoB;IACjE,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7B,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;QAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAC9E,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;QAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,eAAe;IAInB,YAAY,GAAkB;QAiF9B,UAAK,GAAG,CAAC,QAAkB,EAAQ,EAAE;YACnC,QAAQ,CAAC,KAAK,CAAC,eAAe,C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;YACb,MAAM;YACN,IAAI;YACJ,cAAc;YACd,aAAa;YACb,MAAM;YACN,UAAU,CACX,CAAC;IACJ,CAAC;CAqDF;AAED,SAAgB,iBAAiB,CAAY,GAAW;IACtD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IAClB,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC;IACxB,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,IAAI,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAa,EAAE,YAAiC,OAAO;IACtF,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC/C,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;IAC3C,CAAC;IACD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,kBAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspack-plugin-svg-sprite",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "SVG sprite loader and plugin for Rspack — drop-in replacement for svg-sprite-loader with inline and extract mode support",
|
|
5
5
|
"author": "Yichen Zhu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,26 +74,13 @@
|
|
|
74
74
|
"files": [
|
|
75
75
|
"dist/",
|
|
76
76
|
"client.d.ts",
|
|
77
|
+
"CHANGELOG.md",
|
|
77
78
|
"README.md",
|
|
78
79
|
"LICENSE"
|
|
79
80
|
],
|
|
80
|
-
"scripts": {
|
|
81
|
-
"build": "tsc",
|
|
82
|
-
"test": "tsc && rstest run",
|
|
83
|
-
"test:ci": "tsc && rstest run --coverage",
|
|
84
|
-
"typecheck": "tsc --noEmit",
|
|
85
|
-
"lint": "eslint src/",
|
|
86
|
-
"lint:fix": "eslint src/ --fix",
|
|
87
|
-
"format": "prettier --write .",
|
|
88
|
-
"format:check": "prettier --check .",
|
|
89
|
-
"dev:rspack": "pnpm --filter svg-sprite-consumer-demo dev",
|
|
90
|
-
"dev:webpack": "pnpm --filter svg-sprite-webpack-demo dev",
|
|
91
|
-
"prepublishOnly": "pnpm build",
|
|
92
|
-
"prepare": "husky"
|
|
93
|
-
},
|
|
94
81
|
"peerDependencies": {
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
82
|
+
"@rsbuild/core": ">=1.0.0",
|
|
83
|
+
"@rspack/core": ">=0.5.0"
|
|
97
84
|
},
|
|
98
85
|
"peerDependenciesMeta": {
|
|
99
86
|
"@rspack/core": {
|
|
@@ -104,29 +91,39 @@
|
|
|
104
91
|
}
|
|
105
92
|
},
|
|
106
93
|
"devDependencies": {
|
|
94
|
+
"@changesets/changelog-github": "1.0.1",
|
|
95
|
+
"@changesets/cli": "3.0.3",
|
|
107
96
|
"@eslint/js": "^10.0.1",
|
|
97
|
+
"@rsbuild/core": "1.7.3",
|
|
108
98
|
"@rspack/core": "^1.7.6",
|
|
109
99
|
"@rstest/core": "^0.8.5",
|
|
110
100
|
"@rstest/coverage-istanbul": "^0.2.1",
|
|
111
101
|
"eslint": "^10.0.1",
|
|
112
102
|
"eslint-config-prettier": "^10.1.8",
|
|
103
|
+
"htmlparser2": "9.1.0",
|
|
113
104
|
"husky": "^9.1.7",
|
|
114
105
|
"lint-staged": "^16.2.7",
|
|
115
106
|
"prettier": "^3.8.1",
|
|
116
|
-
"
|
|
107
|
+
"rsbuild-v2": "npm:@rsbuild/core@2.3.2",
|
|
108
|
+
"rspack-v2": "npm:@rspack/core@2.3.2",
|
|
109
|
+
"svgo": "4.1.0",
|
|
110
|
+
"svgo-loader": "5.0.0",
|
|
117
111
|
"typescript": "^5.9.3",
|
|
118
|
-
"typescript-eslint": "^8.56.0"
|
|
112
|
+
"typescript-eslint": "^8.56.0",
|
|
113
|
+
"webpack": "5.105.2"
|
|
119
114
|
},
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
"scripts": {
|
|
116
|
+
"build": "tsc",
|
|
117
|
+
"test": "tsc && rstest run",
|
|
118
|
+
"test:ci": "tsc && rstest run --coverage",
|
|
119
|
+
"typecheck": "tsc --noEmit",
|
|
120
|
+
"lint": "eslint src/",
|
|
121
|
+
"lint:fix": "eslint src/ --fix",
|
|
122
|
+
"format": "prettier --write .",
|
|
123
|
+
"format:check": "prettier --check .",
|
|
124
|
+
"dev:rspack": "pnpm build && pnpm --filter svg-sprite-consumer-demo dev",
|
|
125
|
+
"dev:webpack": "pnpm --filter svg-sprite-webpack-demo dev",
|
|
126
|
+
"changeset": "changeset",
|
|
127
|
+
"version-packages": "changeset version"
|
|
131
128
|
}
|
|
132
|
-
}
|
|
129
|
+
}
|