vite-svg-sprite-generator-plugin 1.1.1 β†’ 1.1.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 CHANGED
@@ -25,7 +25,7 @@ All notable changes to this project will be documented in this file.
25
25
 
26
26
  ---
27
27
 
28
- ## [1.1.0] - 2025-10-26
28
+ ## [1.1.0] - 2025-10-25
29
29
 
30
30
  ### πŸ”’ Security
31
31
 
@@ -91,7 +91,19 @@ No changes required for existing users. All improvements are transparent.
91
91
 
92
92
  ---
93
93
 
94
- ## [1.0.0] - 2025-10-26
94
+ ## [1.0.1] - 2025-10-24
95
+
96
+ ### 🎨 Documentation & Improvements
97
+
98
+ - **IMPROVED:** Updated README with inline SVG behavior documentation
99
+ - **ADDED:** Clarification that sprite is injected into page DOM
100
+ - **ADDED:** "How It Works" section in README
101
+ - **ADDED:** "Why Inline SVG?" section explaining benefits
102
+ - **IMPROVED:** Better documentation of sprite injection behavior
103
+
104
+ ---
105
+
106
+ ## [1.0.0] - 2025-10-23
95
107
 
96
108
  ### πŸŽ‰ Initial Release
97
109
 
package/README.md CHANGED
@@ -11,10 +11,13 @@
11
11
  - ⚑ **Hot Module Replacement** - Instant updates without page reload during development
12
12
  - πŸ”’ **Security First** - Built-in XSS protection and path traversal prevention
13
13
  - πŸ’Ύ **Smart Caching** - Efficient caching with mtime-based validation
14
- - 🎯 **Auto-Injection** - Automatic sprite injection into HTML
14
+ - 🎯 **Auto-Injection** - Sprite is automatically injected into HTML as inline SVG (no separate file)
15
+ - πŸ“„ **Inline SVG** - Sprite is inserted directly into the page DOM, no external requests
15
16
  - πŸ”§ **Fully Configurable** - Extensive customization options
16
17
  - πŸ“¦ **Zero Config** - Works out of the box with sensible defaults
17
18
  - 🌳 **Tree-Shakeable** - ES modules with proper exports
19
+ - 🎨 **Vite Standard Compliance** - Fully complies with Vite plugin API and ecosystem standards
20
+ - πŸ”„ **Uses Vite Utilities** - Leverages `vite.normalizePath` for consistent cross-platform path handling
18
21
 
19
22
  ## πŸ“¦ Installation
20
23
 
@@ -92,6 +95,43 @@ src/
92
95
 
93
96
  That's it! πŸŽ‰
94
97
 
98
+ ## 🎨 How It Works
99
+
100
+ The plugin automatically **injects the sprite directly into your HTML** as an inline SVG element.
101
+
102
+ βœ… **No separate file generated** - Sprite is embedded in the page DOM
103
+ βœ… **No external requests** - Everything works in a single HTTP request
104
+ βœ… **Automatic injection** - Sprite appears in HTML automatically
105
+ βœ… **Fast rendering** - Icons display immediately, no loading delay
106
+
107
+ ### Where is the sprite?
108
+
109
+ Look for this in your HTML:
110
+
111
+ ```html
112
+ <svg id="icon-sprite" class="svg-sprite" style="display: none;">
113
+ <symbol id="home" viewBox="0 0 24 24">...</symbol>
114
+ <symbol id="user" viewBox="0 0 24 24">...</symbol>
115
+ </svg>
116
+ ```
117
+
118
+ The sprite is **injected at the start of your HTML** (just after `<body>` tag).
119
+
120
+ ## 🎨 Vite Compliance
121
+
122
+ This plugin is built with maximum compliance to Vite standards and best practices:
123
+
124
+ - βœ… **Official Vite Plugin API** - Implements all required hooks (`buildStart`, `buildEnd`, `configureServer`, `handleHotUpdate`)
125
+ - βœ… **Uses Vite Internal Utilities** - Leverages `vite.normalizePath` for cross-platform path normalization
126
+ - βœ… **Vite HMR Integration** - Properly integrates with Vite's HMR system for instant updates
127
+ - βœ… **Vite Config Integration** - Respects all Vite configuration options (mode, command, etc.)
128
+ - βœ… **Async/Await Standards** - Uses modern async patterns following Vite conventions
129
+ - βœ… **TypeScript Support** - Full TypeScript definitions for better DX
130
+ - βœ… **No Breaking Changes** - Follows semantic versioning and Vite ecosystem standards
131
+ - βœ… **Zero Vite Configuration Override** - Doesn't interfere with other Vite plugins or features
132
+
133
+ The plugin seamlessly integrates into your Vite workflow without any conflicts.
134
+
95
135
  ## πŸ“– Documentation
96
136
 
97
137
  ### Options
@@ -280,35 +320,6 @@ Advanced SVG sanitization with precompiled RegExp patterns:
280
320
  </svg>
281
321
  ```
282
322
 
283
- ### CSS Styling
284
-
285
- ```css
286
- /* Basic styling */
287
- .icon {
288
- width: 24px;
289
- height: 24px;
290
- fill: currentColor;
291
- }
292
-
293
- /* Color variants */
294
- .icon-primary {
295
- fill: #007bff;
296
- }
297
-
298
- .icon-danger {
299
- fill: #dc3545;
300
- }
301
-
302
- /* With transitions */
303
- .icon {
304
- transition: fill 0.3s ease;
305
- }
306
-
307
- .icon:hover {
308
- fill: #0056b3;
309
- }
310
- ```
311
-
312
323
  ### React/Vue/Svelte
313
324
 
314
325
  ```jsx
@@ -359,6 +370,8 @@ defineProps(['name']);
359
370
  </svg>
360
371
  ```
361
372
 
373
+ ---
374
+
362
375
  ## πŸ“Š Performance
363
376
 
364
377
  ### Optimization Results
@@ -379,117 +392,16 @@ sun.svg : 305 β†’ 287 bytes (-5.9%)
379
392
 
380
393
  **Average reduction: 40-50%** πŸŽ‰
381
394
 
382
- ## πŸ”§ Advanced Features
383
-
384
- ### HMR Support
385
-
386
- The plugin includes built-in Hot Module Replacement support:
387
-
388
- - βœ… Add new icons β†’ instant update
389
- - βœ… Modify icons β†’ instant update
390
- - βœ… Delete icons β†’ instant update
391
- - βœ… No page reload needed
392
-
393
- ### Security Features
394
-
395
- - βœ… XSS protection (removes `<script>` tags)
396
- - βœ… Event handler removal
397
- - βœ… JavaScript URL filtering
398
- - βœ… Path traversal prevention
399
- - βœ… File size limits (5MB max)
400
-
401
- ### Caching
402
-
403
- - βœ… LRU-like cache with mtime validation
404
- - βœ… Automatic cache invalidation
405
- - βœ… Memory-efficient (max 500 entries)
406
-
407
- ### Duplicate Detection
408
-
409
- ```
410
- ⚠️ Duplicate symbol ID detected: icon-home from home.svg
411
- ```
412
-
413
- Automatic detection and handling of duplicate IDs.
414
-
415
- ## πŸ› Troubleshooting
416
-
417
- ### Icons Not Showing
418
-
419
- 1. Check that sprite is injected:
420
- ```javascript
421
- document.getElementById('icon-sprite')
422
- ```
423
-
424
- 2. Verify icon ID (default - no prefix):
425
- ```html
426
- <use href="#home"></use> <!-- Correct (default) -->
427
- <use href="#icon-home"></use> <!-- Only if you set idPrefix: 'icon' -->
428
- ```
429
-
430
- 3. Check console for errors
431
-
432
- 4. Inspect sprite to see actual symbol IDs:
433
- ```javascript
434
- document.querySelectorAll('#icon-sprite symbol')
435
- ```
436
-
437
- ### SVGO Not Installed Warning
438
-
439
- If you see:
440
- ```
441
- ⚠️ SVGO not installed. Optimization disabled.
442
- ```
443
-
444
- **Option 1 - Install SVGO (recommended for production):**
445
- ```bash
446
- npm install -D svgo
447
- ```
448
-
449
- **Option 2 - Disable the warning:**
450
- ```javascript
451
- svgSpritePlugin({
452
- svgoOptimize: false // Don't try to use SVGO
453
- })
454
- ```
455
-
456
- **Option 3 - Ignore it:**
457
- The plugin works fine without SVGO! The warning is just informational.
458
-
459
- ### SVGO Issues
460
-
461
- If icons look broken after SVGO optimization:
462
-
463
- ```javascript
464
- svgSpritePlugin({
465
- svgoOptimize: false // Disable temporarily
466
- })
467
- ```
468
-
469
- Or use safer config:
470
-
471
- ```javascript
472
- svgoConfig: {
473
- plugins: [
474
- 'preset-default',
475
- { name: 'removeViewBox', active: false }
476
- ]
477
- }
478
- ```
479
-
480
- ### HMR Not Working
481
-
482
- Ensure `watch: true` is set:
395
+ ## πŸ“ Changelog
483
396
 
484
- ```javascript
485
- svgSpritePlugin({
486
- watch: true // Should be enabled by default
487
- })
488
- ```
397
+ ### v1.1.1 (2025-10-26)
489
398
 
490
- ## πŸ“ Changelog
399
+ - πŸ”§ **Using `vite.normalizePath`** - Better cross-platform compatibility
400
+ - ⚑ Improved Windows/Unix path handling
401
+ - πŸ› Better edge case support (network paths, etc.)
402
+ - βœ… **No Breaking Changes** - Fully backward compatible
491
403
 
492
- ### v1.1.0 (2025-10-26)
404
+ ### v1.1.0 (2025-10-25)
493
405
 
494
406
  - πŸ”’ **Path Traversal Protection** - Secure path validation
495
407
  - ⚑ **100% Async FS** - No event loop blocking
@@ -497,59 +409,24 @@ svgSpritePlugin({
497
409
  - πŸ“ **Better Errors** - Detailed messages with examples
498
410
  - βœ… **No Breaking Changes** - Fully backward compatible
499
411
 
500
- ### v3.2.0 (2025-10-26)
501
-
502
- - πŸŽ‰ **SVGO is now OPTIONAL** - Plugin works without it!
503
- - πŸ“¦ Smaller installation (~1.5 MB saved without SVGO)
504
- - ✨ Automatic SVGO detection with graceful fallback
505
- - πŸ”„ Dynamic import - SVGO loaded only when available
506
- - ⚑ No breaking changes
412
+ ### v1.0.1 (2025-10-24)
507
413
 
508
- ### v3.1.1 (2025-10-26)
414
+ - πŸ“š **Documentation Updates** - Clarified inline SVG behavior
415
+ - πŸ“„ Added "How It Works" section
416
+ - πŸ’‘ Added "Why Inline SVG?" section explaining benefits
509
417
 
510
- - πŸ”„ Changed default `idPrefix` to empty string
511
- - Symbol IDs are now just filenames (e.g., `home` instead of `icon-home`)
418
+ ### v1.0.0 (2025-10-23)
512
419
 
513
- ### v3.1.0 (2025-10-26)
420
+ - πŸŽ‰ **Initial Release** - Production-ready Vite plugin
421
+ - πŸš€ SVGO Optimization - 40-60% size reduction
422
+ - ⚑ Hot Module Replacement - Instant updates
423
+ - πŸ”’ Security First - XSS protection and path traversal prevention
424
+ - πŸ’Ύ Smart Caching - LRU-like cache with mtime validation
425
+ - 🎯 Auto-Injection - Automatic sprite injection into HTML
426
+ - πŸ“¦ Zero Config - Works out of the box
427
+ - 🌳 Tree-Shakeable - ES modules with proper exports
514
428
 
515
- - ✨ Added SVGO optimization support
516
- - ✨ Automatic optimization in production
517
- - ✨ Configurable SVGO settings
518
- - πŸ› Fixed memory leak in configureServer
519
- - πŸ“š Improved documentation
520
-
521
- ### v3.0.2 (2025-10-26)
522
-
523
- - πŸ› Critical memory leak fix
524
- - πŸ”’ Enhanced security measures
525
- - ⚑ Performance improvements
526
-
527
- ### v3.0.0
528
-
529
- - ✨ Complete rewrite with TypeScript
530
- - ✨ HMR support
531
- - ✨ Security features
532
- - ✨ Smart caching
533
-
534
- ## 🀝 Contributing
535
-
536
- Contributions are welcome! Please feel free to submit a Pull Request.
537
-
538
- ### Development Setup
539
-
540
- ```bash
541
- # Clone repository
542
- git clone https://github.com/german-schneck/vite-svg-sprite-generator-plugin.git
543
-
544
- # Install dependencies
545
- npm install
546
-
547
- # Run tests
548
- npm test
549
-
550
- # Build
551
- npm run build
552
- ```
429
+ For the complete changelog, see [CHANGELOG.md](CHANGELOG.md)
553
430
 
554
431
  ## πŸ“„ License
555
432
 
@@ -562,8 +439,8 @@ MIT Β© Karev G.S.
562
439
 
563
440
  ## πŸ“§ Support
564
441
 
565
- - πŸ› [Issues](https://github.com/german-schneck/vite-svg-sprite-generator-plugin/issues)
566
- - πŸ’¬ [Discussions](https://github.com/german-schneck/vite-svg-sprite-generator-plugin/discussions)
442
+ - πŸ› [Issues](https://github.com/gkarev/vite-svg-sprite-generator-plugin/issues)
443
+ - πŸ’¬ [Discussions](https://github.com/gkarev/vite-svg-sprite-generator-plugin/discussions)
567
444
 
568
445
  ---
569
446
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-svg-sprite-generator-plugin",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Production-ready Vite plugin for automatic SVG sprite generation with HMR support, SVGO optimization, and security features",
5
5
  "main": "vite-svg-sprite-generator-plugin.js",
6
6
  "module": "vite-svg-sprite-generator-plugin.js",
@@ -43,7 +43,7 @@
43
43
  "license": "MIT",
44
44
  "repository": {
45
45
  "type": "git",
46
- "url": "https://github.com/gkarev/vite-svg-sprite-generator-plugin.git"
46
+ "url": "git+https://github.com/gkarev/vite-svg-sprite-generator-plugin.git"
47
47
  },
48
48
  "bugs": {
49
49
  "url": "https://github.com/gkarev/vite-svg-sprite-generator-plugin/issues"
@@ -66,4 +66,3 @@
66
66
  "node": ">=14.18.0"
67
67
  }
68
68
  }
69
-
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Vite SVG Sprite Plugin - TypeScript Definitions (Production-Ready)
3
- * @version 3.1.0 - SVGO optimization integration
3
+ * @version 1.1.1 - Cross-platform path handling with vite.normalizePath
4
4
  */
5
5
 
6
6
  import type { Plugin } from 'vite';
@@ -39,8 +39,9 @@ export interface SvgSpritePluginOptions {
39
39
  idPrefix?: string;
40
40
 
41
41
  /**
42
- * ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ SVG (будущая функция)
42
+ * Enable optimization (legacy option)
43
43
  * @default true
44
+ * @deprecated Use svgoOptimize instead for better control
44
45
  */
45
46
  optimize?: boolean;
46
47
 
@@ -91,7 +92,7 @@ export interface SpriteIcon {
91
92
  * @example
92
93
  * ```ts
93
94
  * import { defineConfig } from 'vite';
94
- * import svgSpritePlugin from './vite-svg-sprite-plugin';
95
+ * import svgSpritePlugin from 'vite-svg-sprite-generator-plugin';
95
96
  *
96
97
  * export default defineConfig({
97
98
  * plugins: [