vite-svg-sprite-generator-plugin 1.1.1 β†’ 1.1.2

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,45 @@ 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" xmlns="http://www.w3.org/2000/svg">
113
+ <defs>
114
+ <symbol id="home">...</symbol>
115
+ <symbol id="user">...</symbol>
116
+ </defs>
117
+ </svg>
118
+ ```
119
+
120
+ The sprite is **injected at the end of your HTML** (just before `</body>` tag).
121
+
122
+ ## 🎨 Vite Compliance
123
+
124
+ This plugin is built with maximum compliance to Vite standards and best practices:
125
+
126
+ - βœ… **Official Vite Plugin API** - Implements all required hooks (`buildStart`, `buildEnd`, `configureServer`, `handleHotUpdate`)
127
+ - βœ… **Uses Vite Internal Utilities** - Leverages `vite.normalizePath` for cross-platform path normalization
128
+ - βœ… **Vite HMR Integration** - Properly integrates with Vite's HMR system for instant updates
129
+ - βœ… **Vite Config Integration** - Respects all Vite configuration options (mode, command, etc.)
130
+ - βœ… **Async/Await Standards** - Uses modern async patterns following Vite conventions
131
+ - βœ… **TypeScript Support** - Full TypeScript definitions for better DX
132
+ - βœ… **No Breaking Changes** - Follows semantic versioning and Vite ecosystem standards
133
+ - βœ… **Zero Vite Configuration Override** - Doesn't interfere with other Vite plugins or features
134
+
135
+ The plugin seamlessly integrates into your Vite workflow without any conflicts.
136
+
95
137
  ## πŸ“– Documentation
96
138
 
97
139
  ### Options
@@ -280,35 +322,6 @@ Advanced SVG sanitization with precompiled RegExp patterns:
280
322
  </svg>
281
323
  ```
282
324
 
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
325
  ### React/Vue/Svelte
313
326
 
314
327
  ```jsx
@@ -359,6 +372,8 @@ defineProps(['name']);
359
372
  </svg>
360
373
  ```
361
374
 
375
+ ---
376
+
362
377
  ## πŸ“Š Performance
363
378
 
364
379
  ### Optimization Results
@@ -379,117 +394,16 @@ sun.svg : 305 β†’ 287 bytes (-5.9%)
379
394
 
380
395
  **Average reduction: 40-50%** πŸŽ‰
381
396
 
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:
397
+ ## πŸ“ Changelog
483
398
 
484
- ```javascript
485
- svgSpritePlugin({
486
- watch: true // Should be enabled by default
487
- })
488
- ```
399
+ ### v1.1.1 (2025-10-26)
489
400
 
490
- ## πŸ“ Changelog
401
+ - πŸ”§ **Using `vite.normalizePath`** - Better cross-platform compatibility
402
+ - ⚑ Improved Windows/Unix path handling
403
+ - πŸ› Better edge case support (network paths, etc.)
404
+ - βœ… **No Breaking Changes** - Fully backward compatible
491
405
 
492
- ### v1.1.0 (2025-10-26)
406
+ ### v1.1.0 (2025-10-25)
493
407
 
494
408
  - πŸ”’ **Path Traversal Protection** - Secure path validation
495
409
  - ⚑ **100% Async FS** - No event loop blocking
@@ -497,59 +411,24 @@ svgSpritePlugin({
497
411
  - πŸ“ **Better Errors** - Detailed messages with examples
498
412
  - βœ… **No Breaking Changes** - Fully backward compatible
499
413
 
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
414
+ ### v1.0.1 (2025-10-24)
507
415
 
508
- ### v3.1.1 (2025-10-26)
416
+ - πŸ“š **Documentation Updates** - Clarified inline SVG behavior
417
+ - πŸ“„ Added "How It Works" section
418
+ - πŸ’‘ Added "Why Inline SVG?" section explaining benefits
509
419
 
510
- - πŸ”„ Changed default `idPrefix` to empty string
511
- - Symbol IDs are now just filenames (e.g., `home` instead of `icon-home`)
420
+ ### v1.0.0 (2025-10-23)
512
421
 
513
- ### v3.1.0 (2025-10-26)
422
+ - πŸŽ‰ **Initial Release** - Production-ready Vite plugin
423
+ - πŸš€ SVGO Optimization - 40-60% size reduction
424
+ - ⚑ Hot Module Replacement - Instant updates
425
+ - πŸ”’ Security First - XSS protection and path traversal prevention
426
+ - πŸ’Ύ Smart Caching - LRU-like cache with mtime validation
427
+ - 🎯 Auto-Injection - Automatic sprite injection into HTML
428
+ - πŸ“¦ Zero Config - Works out of the box
429
+ - 🌳 Tree-Shakeable - ES modules with proper exports
514
430
 
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
- ```
431
+ For the complete changelog, see [CHANGELOG.md](CHANGELOG.md)
553
432
 
554
433
  ## πŸ“„ License
555
434
 
@@ -562,8 +441,8 @@ MIT Β© Karev G.S.
562
441
 
563
442
  ## πŸ“§ Support
564
443
 
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)
444
+ - πŸ› [Issues](https://github.com/gkarev/vite-svg-sprite-generator-plugin/issues)
445
+ - πŸ’¬ [Discussions](https://github.com/gkarev/vite-svg-sprite-generator-plugin/discussions)
567
446
 
568
447
  ---
569
448
 
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.2",
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",
@@ -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: [