svger-cli 2.0.8 → 3.0.0
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 +159 -0
- package/README.md +348 -15
- package/dist/index.d.ts +30 -0
- package/dist/index.js +33 -0
- package/dist/integrations/babel.d.ts +58 -0
- package/dist/integrations/babel.js +221 -0
- package/dist/integrations/jest-preset.d.ts +44 -0
- package/dist/integrations/jest-preset.js +169 -0
- package/dist/integrations/nextjs.d.ts +56 -0
- package/dist/integrations/nextjs.js +140 -0
- package/dist/integrations/rollup.d.ts +29 -0
- package/dist/integrations/rollup.js +197 -0
- package/dist/integrations/vite.d.ts +29 -0
- package/dist/integrations/vite.js +221 -0
- package/dist/integrations/webpack.d.ts +84 -0
- package/dist/integrations/webpack.js +273 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -1
- package/dist/types/integrations.d.ts +255 -0
- package/dist/types/integrations.js +4 -0
- package/docs/INTEGRATION-IMPLEMENTATION-SUMMARY.md +448 -0
- package/docs/INTEGRATIONS.md +543 -0
- package/examples/babel.config.example.js +182 -0
- package/examples/jest.config.example.js +158 -0
- package/examples/next.config.example.js +133 -0
- package/examples/rollup.config.example.js +129 -0
- package/examples/vite.config.example.js +98 -0
- package/examples/webpack.config.example.js +88 -0
- package/package.json +74 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,151 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
|
|
6
6
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.0.0] - 2025-11-26
|
|
9
|
+
|
|
10
|
+
### 🎉 Major Release - Official Build Tool Integrations
|
|
11
|
+
|
|
12
|
+
This major release introduces **official build tool integrations**, making SVGER-CLI the most
|
|
13
|
+
comprehensive SVG-to-component solution with first-class support for all major build tools and
|
|
14
|
+
frameworks.
|
|
15
|
+
|
|
16
|
+
### Added - Build Tool Integrations
|
|
17
|
+
|
|
18
|
+
#### **Webpack Integration** (`svger-cli/webpack`)
|
|
19
|
+
|
|
20
|
+
- ✅ Full webpack plugin with HMR (Hot Module Replacement) support
|
|
21
|
+
- ✅ Webpack loader for inline SVG transformation
|
|
22
|
+
- ✅ Watch mode with intelligent debouncing
|
|
23
|
+
- ✅ Asset emission directly to webpack compilation
|
|
24
|
+
- ✅ TypeScript support with full type definitions
|
|
25
|
+
- ✅ Multi-framework support (React, Vue, Angular, etc.)
|
|
26
|
+
|
|
27
|
+
#### **Vite Plugin** (`svger-cli/vite`)
|
|
28
|
+
|
|
29
|
+
- ✅ Native Vite plugin with lightning-fast HMR
|
|
30
|
+
- ✅ Virtual module support for dynamic imports
|
|
31
|
+
- ✅ Dev server integration with instant updates
|
|
32
|
+
- ✅ Build optimization and tree-shaking
|
|
33
|
+
- ✅ Named and default export options
|
|
34
|
+
- ✅ Source map generation
|
|
35
|
+
|
|
36
|
+
#### **Rollup Plugin** (`svger-cli/rollup`)
|
|
37
|
+
|
|
38
|
+
- ✅ Full Rollup plugin with tree-shaking support
|
|
39
|
+
- ✅ Load and transform hooks for SVG files
|
|
40
|
+
- ✅ Source map generation for debugging
|
|
41
|
+
- ✅ Bundle optimization for production
|
|
42
|
+
- ✅ Library-friendly named exports
|
|
43
|
+
- ✅ Zero runtime overhead
|
|
44
|
+
|
|
45
|
+
#### **Babel Plugin** (`svger-cli/babel`)
|
|
46
|
+
|
|
47
|
+
- ✅ Complete Babel plugin with visitor pattern
|
|
48
|
+
- ✅ Automatic import transformation (SVG → Component)
|
|
49
|
+
- ✅ Dynamic import support (`import('./icon.svg')`)
|
|
50
|
+
- ✅ Pre-build SVG processing
|
|
51
|
+
- ✅ Works with Create React App, Gatsby, Vue CLI
|
|
52
|
+
- ✅ Framework-agnostic with full TypeScript support
|
|
53
|
+
|
|
54
|
+
#### **Next.js Integration** (`svger-cli/nextjs`)
|
|
55
|
+
|
|
56
|
+
- ✅ `withSvger` wrapper for seamless Next.js integration
|
|
57
|
+
- ✅ Server-Side Rendering (SSR) support
|
|
58
|
+
- ✅ App Router and Pages Router compatibility
|
|
59
|
+
- ✅ Webpack configuration extension
|
|
60
|
+
- ✅ Hot Module Replacement for development
|
|
61
|
+
- ✅ TypeScript support out of the box
|
|
62
|
+
|
|
63
|
+
#### **Jest Preset** (`svger-cli/jest`)
|
|
64
|
+
|
|
65
|
+
- ✅ Complete Jest transformer for SVG files
|
|
66
|
+
- ✅ Jest preset configuration
|
|
67
|
+
- ✅ Custom transformer factory
|
|
68
|
+
- ✅ Mock mode for faster test execution
|
|
69
|
+
- ✅ CommonJS and ES module support
|
|
70
|
+
- ✅ Multi-framework compatibility
|
|
71
|
+
|
|
72
|
+
### Added - Package Infrastructure
|
|
73
|
+
|
|
74
|
+
- **11 New Export Paths**: Added dedicated exports for all integrations
|
|
75
|
+
- `./webpack`, `./webpack-loader`
|
|
76
|
+
- `./vite`
|
|
77
|
+
- `./rollup`
|
|
78
|
+
- `./babel`, `./babel-plugin`
|
|
79
|
+
- `./nextjs`
|
|
80
|
+
- `./jest`, `./jest-transformer`, `./jest-preset`
|
|
81
|
+
|
|
82
|
+
- **Comprehensive Documentation**:
|
|
83
|
+
- New `docs/INTEGRATIONS.md` - Complete integration guide (500+ lines)
|
|
84
|
+
- New `docs/INTEGRATION-IMPLEMENTATION-SUMMARY.md` - Implementation overview
|
|
85
|
+
- 6 example configuration files in `examples/` directory
|
|
86
|
+
- Updated API documentation with integration examples
|
|
87
|
+
|
|
88
|
+
- **Enhanced Testing**:
|
|
89
|
+
- New integration verification test suite
|
|
90
|
+
- 100% integration test coverage (7/7 passing)
|
|
91
|
+
- Automated testing for all build tool integrations
|
|
92
|
+
- New `test:integrations` npm script
|
|
93
|
+
|
|
94
|
+
- **Updated Keywords**: Added 18+ new npm keywords:
|
|
95
|
+
- Build tools: `webpack`, `webpack-plugin`, `webpack-loader`
|
|
96
|
+
- Bundlers: `vite`, `vite-plugin`, `rollup`, `rollup-plugin`
|
|
97
|
+
- Transpilers: `babel`, `babel-plugin`, `babel-transform`
|
|
98
|
+
- Frameworks: `nextjs`, `next-js`
|
|
99
|
+
- Testing: `jest`, `jest-preset`, `jest-transformer`
|
|
100
|
+
- General: `build-tools`, `bundler`, `hmr`, `hot-module-replacement`
|
|
101
|
+
|
|
102
|
+
### Changed
|
|
103
|
+
|
|
104
|
+
- **Package Description**: Updated to highlight official build tool integrations
|
|
105
|
+
- **Main Index**: Reorganized exports to include all integration plugins
|
|
106
|
+
- **Type Definitions**: Enhanced TypeScript types for all integrations
|
|
107
|
+
- **Documentation Structure**: Improved organization with dedicated integration docs
|
|
108
|
+
|
|
109
|
+
### Features Comparison
|
|
110
|
+
|
|
111
|
+
| Feature | Webpack | Vite | Rollup | Babel | Next.js | Jest |
|
|
112
|
+
| ------------------ | ------- | ---- | ------ | ----- | ------- | ---- |
|
|
113
|
+
| HMR Support | ✅ | ✅ | ❌ | ❌ | ✅ | N/A |
|
|
114
|
+
| Source Maps | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
|
|
115
|
+
| SSR Support | ❌ | ✅ | ❌ | ❌ | ✅ | N/A |
|
|
116
|
+
| Virtual Modules | ❌ | ✅ | ❌ | ❌ | ❌ | N/A |
|
|
117
|
+
| Watch Mode | ✅ | ✅ | ✅ | ✅ | ✅ | N/A |
|
|
118
|
+
| Import Transform | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
119
|
+
| Dynamic Imports | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
120
|
+
| Framework Agnostic | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ |
|
|
121
|
+
|
|
122
|
+
### Migration Guide from 2.x to 3.0
|
|
123
|
+
|
|
124
|
+
**No Breaking Changes for CLI Users**: If you're using the CLI (`svger-cli`), everything works
|
|
125
|
+
exactly as before.
|
|
126
|
+
|
|
127
|
+
**New Features for Build Tool Users**:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Install
|
|
131
|
+
npm install svger-cli@3.0.0 --save-dev
|
|
132
|
+
|
|
133
|
+
# Use with your build tool
|
|
134
|
+
# See docs/INTEGRATIONS.md for detailed examples
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Performance
|
|
138
|
+
|
|
139
|
+
- Zero runtime dependencies
|
|
140
|
+
- 85% faster than SVGR for batch processing
|
|
141
|
+
- Tree-shakeable exports - only bundle what you use
|
|
142
|
+
- Optimized build tool integrations with minimal overhead
|
|
143
|
+
|
|
144
|
+
### Documentation
|
|
145
|
+
|
|
146
|
+
- Complete integration guide in `docs/INTEGRATIONS.md`
|
|
147
|
+
- 6 working example configurations in `examples/` directory
|
|
148
|
+
- Updated README with integration quick-start
|
|
149
|
+
- Enhanced API documentation
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
8
153
|
## [2.0.7] - 2025-11-20
|
|
9
154
|
|
|
10
155
|
### Fixed
|
|
@@ -81,6 +226,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
81
226
|
## [Unreleased] - 2025-11-12
|
|
82
227
|
|
|
83
228
|
### Added
|
|
229
|
+
|
|
84
230
|
- Comprehensive performance analysis documentation with detailed technical breakdown
|
|
85
231
|
- Professional competitive analysis with fair tool comparisons
|
|
86
232
|
- Transparency section welcoming community feedback
|
|
@@ -89,6 +235,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
89
235
|
- Research sources and feedback channels for documentation accuracy
|
|
90
236
|
|
|
91
237
|
### Changed
|
|
238
|
+
|
|
92
239
|
- Corrected SVGR description to acknowledge webpack ecosystem support (not React-only)
|
|
93
240
|
- Clarified 85% performance improvement claim with proper context and scope
|
|
94
241
|
- Enhanced "Advanced Props" definition vs standard SVG props
|
|
@@ -97,6 +244,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
97
244
|
- Updated documentation tone to be educational rather than competitive
|
|
98
245
|
|
|
99
246
|
### Fixed
|
|
247
|
+
|
|
100
248
|
- Inaccurate claims about competitor tools' capabilities
|
|
101
249
|
- Misleading performance comparisons without proper context
|
|
102
250
|
- Unprofessional competitive analysis language
|
|
@@ -105,6 +253,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
105
253
|
## [2.0.5] - 2025-11-11
|
|
106
254
|
|
|
107
255
|
### Fixed
|
|
256
|
+
|
|
108
257
|
- **CRITICAL**: PascalCase component naming preservation
|
|
109
258
|
- Fixed issue where PascalCase filenames were incorrectly converted to lowercase
|
|
110
259
|
- ArrowBendDownLeft.svg → ArrowBendDownLeft.tsx (was: Arrowbenddownleft.tsx)
|
|
@@ -114,12 +263,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
114
263
|
- All 28 framework tests continue passing
|
|
115
264
|
|
|
116
265
|
### Changed
|
|
266
|
+
|
|
117
267
|
- Updated package version to 2.0.5
|
|
118
268
|
- Enhanced toPascalCase utility function for better case detection
|
|
119
269
|
|
|
120
270
|
## [2.0.4] - 2025-11-11
|
|
121
271
|
|
|
122
272
|
### Added
|
|
273
|
+
|
|
123
274
|
- Complete 28-property configuration schema
|
|
124
275
|
- React/Vue/Angular specific configuration options
|
|
125
276
|
- Enhanced responsive design support with breakpoint configurations
|
|
@@ -129,6 +280,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
129
280
|
- Enhanced TypeScript support with improved type definitions
|
|
130
281
|
|
|
131
282
|
### Changed
|
|
283
|
+
|
|
132
284
|
- Streamlined ESLint configuration (.eslintrc.js → .eslintrc.cjs)
|
|
133
285
|
- Enhanced component templates with new configuration support
|
|
134
286
|
- Improved configuration management across multiple files
|
|
@@ -136,12 +288,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
136
288
|
- Enhanced comparison tables and installation instructions
|
|
137
289
|
|
|
138
290
|
### Fixed
|
|
291
|
+
|
|
139
292
|
- TypeScript duplicate export errors in index generation
|
|
140
293
|
- Simplified index.ts generation to prevent conflicts
|
|
141
294
|
- Improved configuration validation and error messages
|
|
142
295
|
- Enhanced toPascalCase to preserve existing PascalCase names
|
|
143
296
|
|
|
144
297
|
### Removed
|
|
298
|
+
|
|
145
299
|
- Redundant test documentation files (COMPLETE-TEST-REPORT.md, TEST-RESULTS.md, TESTING-SUMMARY.md)
|
|
146
300
|
- Deprecated ESLint configuration format
|
|
147
301
|
- Outdated package dependencies reducing bundle size
|
|
@@ -175,6 +329,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
175
329
|
- Native module file path resolution error
|
|
176
330
|
|
|
177
331
|
### Removed
|
|
332
|
+
|
|
178
333
|
- Unnecessary test folders and configuration files
|
|
179
334
|
- Redundant package configurations
|
|
180
335
|
|
|
@@ -197,6 +352,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
197
352
|
- TypeScript-first approach with native type generation
|
|
198
353
|
|
|
199
354
|
### Removed
|
|
355
|
+
|
|
200
356
|
- Legacy dependencies reducing package size by 89%
|
|
201
357
|
- Single-framework limitation
|
|
202
358
|
- Dependency-heavy build processes
|
|
@@ -204,17 +360,20 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
204
360
|
## [2.0.0] - 2024-10-30
|
|
205
361
|
|
|
206
362
|
### Added
|
|
363
|
+
|
|
207
364
|
- Complete multi-framework support for all 8 UI frameworks
|
|
208
365
|
- Enhanced CLI commands with comprehensive options
|
|
209
366
|
- Open source project files (CODE_OF_CONDUCT, LICENSE, CONTRIBUTING)
|
|
210
367
|
- Professional project structure and documentation
|
|
211
368
|
|
|
212
369
|
### Changed
|
|
370
|
+
|
|
213
371
|
- Major version release with breaking changes from 1.x
|
|
214
372
|
- Enhanced README with multi-framework guide and benchmarks
|
|
215
373
|
- Consolidated project structure and test organization
|
|
216
374
|
|
|
217
375
|
### Removed
|
|
376
|
+
|
|
218
377
|
- node_modules folder from repository
|
|
219
378
|
- Legacy 1.x architecture and dependencies
|
|
220
379
|
|
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
# SVGER-CLI
|
|
1
|
+
# SVGER-CLI v3.0.0 - Enterprise SVG Processing Framework
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/svger-cli)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
[](https://www.npmjs.com/package/svger-cli)
|
|
7
7
|
|
|
8
|
-
> **The most advanced, zero-dependency SVG to component converter
|
|
9
|
-
>
|
|
10
|
-
>
|
|
8
|
+
> **The most advanced, zero-dependency SVG to component converter with official build tool
|
|
9
|
+
> integrations. First-class support for Webpack, Vite, Rollup, Babel, Next.js, and Jest. Supporting
|
|
10
|
+
> 9+ UI frameworks including React Native with enterprise-grade performance and auto-generated
|
|
11
|
+
> exports.**
|
|
11
12
|
|
|
12
13
|
---
|
|
13
14
|
|
|
@@ -16,7 +17,14 @@
|
|
|
16
17
|
### 🚀 **Getting Started**
|
|
17
18
|
|
|
18
19
|
- [📦 Installation](#-installation)
|
|
19
|
-
- [
|
|
20
|
+
- [� Build Tool Integrations](#-build-tool-integrations) **← NEW in v3.0**
|
|
21
|
+
- [Webpack](#webpack-integration)
|
|
22
|
+
- [Vite](#vite-integration)
|
|
23
|
+
- [Rollup](#rollup-integration)
|
|
24
|
+
- [Babel](#babel-integration)
|
|
25
|
+
- [Next.js](#nextjs-integration)
|
|
26
|
+
- [Jest](#jest-integration)
|
|
27
|
+
- [�🚀 Quick Start: Your First Conversion](#-quick-start-your-first-conversion)
|
|
20
28
|
- [💡 Why SVGER-CLI?](#-why-svger-cli-the-zero-dependency-advantage)
|
|
21
29
|
|
|
22
30
|
### 📚 **Core Documentation**
|
|
@@ -74,6 +82,32 @@
|
|
|
74
82
|
| ------------------------------------- | --------------------------------------------------------------- |
|
|
75
83
|
| 🎯 Get started immediately | [Quick Start](#-quick-start-your-first-conversion) |
|
|
76
84
|
| 📦 Install the package | [Installation](#-installation) |
|
|
85
|
+
| 🔧 Use with Webpack/Vite/Rollup | [Build Tool Integrations](#-build-tool-integrations) **NEW** |
|
|
86
|
+
| ⚙️ Configure Webpack | [Webpack Integration](#webpack-integration) |
|
|
87
|
+
| ⚡ Set up Vite | [Vite Integration](#vite-integration) |
|
|
88
|
+
| 📦 Use with Rollup | [Rollup Integration](#rollup-integration) |
|
|
89
|
+
| 🔄 Integrate Babel | [Babel Integration](#babel-integration) |
|
|
90
|
+
| ▲ Use with Next.js | [Next.js Integration](#nextjs-integration) |
|
|
91
|
+
| 🧪 Set up Jest | [Jest Integration](#jest-integration) |
|
|
92
|
+
| 🤔 Understand why SVGER-CLI is better | [Why SVGER-CLI?](#-why-svger-cli-the-zero-dependency-advantage) |
|
|
93
|
+
| ⚡ Compare features with competitors | [Feature Comparison](#-feature-comparison-matrix) |
|
|
94
|
+
| 🚀 Convert SVGs to React components | [React Guide](#react) |
|
|
95
|
+
| 📱 Use with React Native | [React Native Guide](#react-native) |
|
|
96
|
+
| 💚 Use with Vue | [Vue Guide](#vue-3) |
|
|
97
|
+
| 🅰️ Use with Angular | [Angular Guide](#angular) |
|
|
98
|
+
| 🌪️ Use with Svelte | [Svelte Guide](#svelte) |
|
|
99
|
+
| 📖 Learn all CLI commands | [CLI Reference](#-comprehensive-cli-reference) |
|
|
100
|
+
| 💻 Use the programmatic API | [API Reference](#-programmatic-api) |
|
|
101
|
+
| 🎨 Configure styling & theming | [Styling Guide](#-advanced-styling--theming) |
|
|
102
|
+
| ⚡ Optimize performance | [Performance Guide](#-performance-optimization) |
|
|
103
|
+
| 🚀 Deploy to production | [Deployment Guide](#-production-deployment) |
|
|
104
|
+
| 🐳 Use with Docker | [Docker Setup](#docker-integration) |
|
|
105
|
+
| 🧪 Test my components | [Testing Guide](#-testing--quality-assurance) |
|
|
106
|
+
| 🔧 Configure everything | [Configuration Reference](#-configuration-reference) |
|
|
107
|
+
| 🔌 Create custom plugins | [Plugin Development](#-plugin-development) |
|
|
108
|
+
| 🐛 Fix issues | [Troubleshooting](#-troubleshooting--faq) |
|
|
109
|
+
| 📚 Migrate from another tool | [Migration Guide](#-migration-guide) |
|
|
110
|
+
| 📦 Install the package | [Installation](#-installation) |
|
|
77
111
|
| 🤔 Understand why SVGER-CLI is better | [Why SVGER-CLI?](#-why-svger-cli-the-zero-dependency-advantage) |
|
|
78
112
|
| ⚡ Compare features with competitors | [Feature Comparison](#-feature-comparison-matrix) |
|
|
79
113
|
| 🚀 Convert SVGs to React components | [React Guide](#react) |
|
|
@@ -99,6 +133,30 @@
|
|
|
99
133
|
|
|
100
134
|
## 🌟 **Key Features Overview**
|
|
101
135
|
|
|
136
|
+
### **🔧 Official Build Tool Integrations (NEW in v3.0)**
|
|
137
|
+
|
|
138
|
+
First-class support for all major build tools with zero configuration:
|
|
139
|
+
|
|
140
|
+
- ✅ **Webpack Plugin** - HMR, watch mode, and loader support
|
|
141
|
+
- ✅ **Vite Plugin** - Lightning-fast HMR and virtual modules
|
|
142
|
+
- ✅ **Rollup Plugin** - Tree-shaking and source maps
|
|
143
|
+
- ✅ **Babel Plugin** - Universal transpilation and import transformation
|
|
144
|
+
- ✅ **Next.js Integration** - SSR support for App and Pages Router
|
|
145
|
+
- ✅ **Jest Preset** - SVG transformers and mocking for tests
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// One-line setup for any build tool
|
|
149
|
+
const { SvgerWebpackPlugin } = require('svger-cli/webpack');
|
|
150
|
+
import { svgerVitePlugin } from 'svger-cli/vite';
|
|
151
|
+
import { svgerRollupPlugin } from 'svger-cli/rollup';
|
|
152
|
+
const { svgerBabelPlugin } = require('svger-cli/babel');
|
|
153
|
+
const { withSvger } = require('svger-cli/nextjs');
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**[See full integration guide →](#-build-tool-integrations)**
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
102
160
|
### **✨ Auto-Generated index.ts Exports (Enhanced)**
|
|
103
161
|
|
|
104
162
|
Automatically generates clean index.ts files with a **single, consistent export pattern** that
|
|
@@ -106,11 +164,9 @@ avoids naming conflicts:
|
|
|
106
164
|
|
|
107
165
|
```typescript
|
|
108
166
|
// Auto-generated in your output directory
|
|
109
|
-
//
|
|
167
|
+
// Named exports for tree-shaking
|
|
110
168
|
export { default as ArrowLeft } from './ArrowLeft';
|
|
111
169
|
export { default as ArrowRight } from './ArrowRight';
|
|
112
|
-
export { default as HomeIcon } from './HomeIcon';
|
|
113
|
-
export { default as UserProfile } from './UserProfile';
|
|
114
170
|
|
|
115
171
|
/**
|
|
116
172
|
* SVG Components Index
|
|
@@ -127,15 +183,15 @@ export { default as UserProfile } from './UserProfile';
|
|
|
127
183
|
**Import flexibility:**
|
|
128
184
|
|
|
129
185
|
```typescript
|
|
130
|
-
// Named imports (
|
|
131
|
-
import { ArrowLeft, ArrowRight
|
|
186
|
+
// Named imports (tree-shaking friendly)
|
|
187
|
+
import { ArrowLeft, ArrowRight } from './components';
|
|
132
188
|
|
|
133
|
-
// Namespace import
|
|
189
|
+
// Namespace import
|
|
134
190
|
import * as Icons from './components';
|
|
135
|
-
const ArrowIcon = Icons.ArrowLeft;
|
|
136
191
|
|
|
137
|
-
//
|
|
138
|
-
import
|
|
192
|
+
// Default import
|
|
193
|
+
import Icons from './components';
|
|
194
|
+
const { ArrowLeft } = Icons;
|
|
139
195
|
```
|
|
140
196
|
|
|
141
197
|
### **🎯 Enhanced Props & Styling**
|
|
@@ -228,7 +284,284 @@ npm install --save-dev svger-cli
|
|
|
228
284
|
|
|
229
285
|
---
|
|
230
286
|
|
|
231
|
-
##
|
|
287
|
+
## � **Build Tool Integrations**
|
|
288
|
+
|
|
289
|
+
**NEW in v3.0**: SVGER-CLI now provides official integrations for all major build tools, enabling
|
|
290
|
+
seamless SVG-to-component conversion directly in your build pipeline.
|
|
291
|
+
|
|
292
|
+
### Quick Integration Overview
|
|
293
|
+
|
|
294
|
+
| Build Tool | Package Import | Use Case | Key Features |
|
|
295
|
+
| ----------- | ------------------- | ----------------------- | -------------------------------- |
|
|
296
|
+
| **Webpack** | `svger-cli/webpack` | Modern web apps | HMR, Watch mode, Loader support |
|
|
297
|
+
| **Vite** | `svger-cli/vite` | Lightning-fast dev | HMR, Virtual modules, Dev server |
|
|
298
|
+
| **Rollup** | `svger-cli/rollup` | Libraries & apps | Tree-shaking, Source maps |
|
|
299
|
+
| **Babel** | `svger-cli/babel` | Universal transpilation | Import transform, CRA, Gatsby |
|
|
300
|
+
| **Next.js** | `svger-cli/nextjs` | React SSR apps | SSR support, App Router |
|
|
301
|
+
| **Jest** | `svger-cli/jest` | Testing | SVG mocking, Transformers |
|
|
302
|
+
|
|
303
|
+
### Webpack Integration
|
|
304
|
+
|
|
305
|
+
Perfect for modern webpack-based applications with full HMR support.
|
|
306
|
+
|
|
307
|
+
**Install:**
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
npm install svger-cli --save-dev
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**webpack.config.js:**
|
|
314
|
+
|
|
315
|
+
```javascript
|
|
316
|
+
const { SvgerWebpackPlugin } = require('svger-cli/webpack');
|
|
317
|
+
|
|
318
|
+
module.exports = {
|
|
319
|
+
plugins: [
|
|
320
|
+
new SvgerWebpackPlugin({
|
|
321
|
+
source: './src/icons', // SVG source directory
|
|
322
|
+
output: './src/components/icons', // Output directory
|
|
323
|
+
framework: 'react', // Target framework
|
|
324
|
+
typescript: true, // Generate TypeScript files
|
|
325
|
+
hmr: true, // Enable Hot Module Replacement
|
|
326
|
+
generateIndex: true, // Generate index.ts with exports
|
|
327
|
+
}),
|
|
328
|
+
],
|
|
329
|
+
|
|
330
|
+
// Optional: Use the loader for inline SVG imports
|
|
331
|
+
module: {
|
|
332
|
+
rules: [
|
|
333
|
+
{
|
|
334
|
+
test: /\.svg$/,
|
|
335
|
+
use: ['svger-cli/webpack-loader'],
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Usage in your app:**
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
import { HomeIcon, UserIcon } from './components/icons';
|
|
346
|
+
|
|
347
|
+
function App() {
|
|
348
|
+
return <HomeIcon width={24} height={24} />;
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### Vite Integration
|
|
355
|
+
|
|
356
|
+
Lightning-fast development with HMR and virtual module support.
|
|
357
|
+
|
|
358
|
+
**vite.config.js:**
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
import { svgerVitePlugin } from 'svger-cli/vite';
|
|
362
|
+
|
|
363
|
+
export default {
|
|
364
|
+
plugins: [
|
|
365
|
+
svgerVitePlugin({
|
|
366
|
+
source: './src/icons',
|
|
367
|
+
output: './src/components/icons',
|
|
368
|
+
framework: 'react',
|
|
369
|
+
typescript: true,
|
|
370
|
+
hmr: true, // Hot Module Replacement
|
|
371
|
+
virtualModules: true, // Enable virtual module imports
|
|
372
|
+
}),
|
|
373
|
+
],
|
|
374
|
+
};
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Features:**
|
|
378
|
+
|
|
379
|
+
- ✅ Instant HMR - changes reflect immediately
|
|
380
|
+
- ✅ Virtual modules - `import Icon from 'virtual:svger/icon-name'`
|
|
381
|
+
- ✅ Dev server integration
|
|
382
|
+
- ✅ Optimized production builds
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
### Rollup Integration
|
|
387
|
+
|
|
388
|
+
Ideal for library development and tree-shakeable bundles.
|
|
389
|
+
|
|
390
|
+
**rollup.config.js:**
|
|
391
|
+
|
|
392
|
+
```javascript
|
|
393
|
+
import { svgerRollupPlugin } from 'svger-cli/rollup';
|
|
394
|
+
|
|
395
|
+
export default {
|
|
396
|
+
plugins: [
|
|
397
|
+
svgerRollupPlugin({
|
|
398
|
+
source: './src/icons',
|
|
399
|
+
output: './dist/icons',
|
|
400
|
+
framework: 'react',
|
|
401
|
+
typescript: true,
|
|
402
|
+
sourcemap: true, // Generate source maps
|
|
403
|
+
exportType: 'named', // 'named' or 'default'
|
|
404
|
+
}),
|
|
405
|
+
],
|
|
406
|
+
};
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Perfect for:**
|
|
410
|
+
|
|
411
|
+
- Component libraries
|
|
412
|
+
- Tree-shakeable exports
|
|
413
|
+
- Multi-framework support
|
|
414
|
+
- Production optimization
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
### Babel Integration
|
|
419
|
+
|
|
420
|
+
Universal transpilation with automatic import transformation.
|
|
421
|
+
|
|
422
|
+
**babel.config.js:**
|
|
423
|
+
|
|
424
|
+
```javascript
|
|
425
|
+
const { svgerBabelPlugin } = require('svger-cli/babel');
|
|
426
|
+
|
|
427
|
+
module.exports = {
|
|
428
|
+
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
429
|
+
plugins: [
|
|
430
|
+
[
|
|
431
|
+
svgerBabelPlugin,
|
|
432
|
+
{
|
|
433
|
+
source: './src/icons',
|
|
434
|
+
output: './src/components/icons',
|
|
435
|
+
framework: 'react',
|
|
436
|
+
typescript: true,
|
|
437
|
+
transformImports: true, // Auto-transform SVG imports
|
|
438
|
+
processOnInit: true, // Process all SVGs on plugin init
|
|
439
|
+
generateIndex: true, // Generate barrel exports
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
],
|
|
443
|
+
};
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
**Import transformation:**
|
|
447
|
+
|
|
448
|
+
```javascript
|
|
449
|
+
// Before (write this in your code)
|
|
450
|
+
import HomeIcon from './assets/home.svg';
|
|
451
|
+
|
|
452
|
+
// After (automatically transformed)
|
|
453
|
+
import HomeIcon from './components/icons/HomeIcon';
|
|
454
|
+
|
|
455
|
+
// Use it
|
|
456
|
+
<HomeIcon width={24} height={24} />;
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Works with:**
|
|
460
|
+
|
|
461
|
+
- Create React App
|
|
462
|
+
- Gatsby
|
|
463
|
+
- Vue CLI
|
|
464
|
+
- Any Babel-based setup
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
### Next.js Integration
|
|
469
|
+
|
|
470
|
+
Seamless integration with Next.js App Router and Pages Router.
|
|
471
|
+
|
|
472
|
+
**next.config.js:**
|
|
473
|
+
|
|
474
|
+
```javascript
|
|
475
|
+
const { withSvger } = require('svger-cli/nextjs');
|
|
476
|
+
|
|
477
|
+
module.exports = withSvger({
|
|
478
|
+
svger: {
|
|
479
|
+
source: './public/icons',
|
|
480
|
+
output: './components/icons',
|
|
481
|
+
framework: 'react',
|
|
482
|
+
typescript: true,
|
|
483
|
+
ssr: true, // Server-Side Rendering support
|
|
484
|
+
hmr: true, // Hot Module Replacement
|
|
485
|
+
},
|
|
486
|
+
// ...other Next.js config
|
|
487
|
+
reactStrictMode: true,
|
|
488
|
+
});
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Features:**
|
|
492
|
+
|
|
493
|
+
- ✅ SSR (Server-Side Rendering) support
|
|
494
|
+
- ✅ App Router compatible
|
|
495
|
+
- ✅ Pages Router compatible
|
|
496
|
+
- ✅ Automatic webpack configuration
|
|
497
|
+
- ✅ TypeScript support
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
### Jest Integration
|
|
502
|
+
|
|
503
|
+
Transform SVGs in your tests or mock them for faster execution.
|
|
504
|
+
|
|
505
|
+
**jest.config.js:**
|
|
506
|
+
|
|
507
|
+
**Option 1: Use the preset (recommended)**
|
|
508
|
+
|
|
509
|
+
```javascript
|
|
510
|
+
module.exports = {
|
|
511
|
+
preset: 'svger-cli/jest',
|
|
512
|
+
testEnvironment: 'jsdom',
|
|
513
|
+
};
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Option 2: Manual configuration**
|
|
517
|
+
|
|
518
|
+
```javascript
|
|
519
|
+
module.exports = {
|
|
520
|
+
transform: {
|
|
521
|
+
'\\.svg$': [
|
|
522
|
+
'svger-cli/jest-transformer',
|
|
523
|
+
{
|
|
524
|
+
framework: 'react',
|
|
525
|
+
typescript: true,
|
|
526
|
+
mock: false, // Set true for mock mode
|
|
527
|
+
},
|
|
528
|
+
],
|
|
529
|
+
},
|
|
530
|
+
testEnvironment: 'jsdom',
|
|
531
|
+
};
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
**Mock mode** (faster tests):
|
|
535
|
+
|
|
536
|
+
```javascript
|
|
537
|
+
transform: {
|
|
538
|
+
'\\.svg$': ['svger-cli/jest-transformer', {
|
|
539
|
+
mock: true, // Returns simple mock component
|
|
540
|
+
}],
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
### Complete Integration Documentation
|
|
547
|
+
|
|
548
|
+
For detailed documentation, configuration options, and advanced examples, see:
|
|
549
|
+
|
|
550
|
+
📖 **[Complete Integration Guide](./docs/INTEGRATIONS.md)** - 500+ lines of comprehensive
|
|
551
|
+
documentation
|
|
552
|
+
|
|
553
|
+
**What's included:**
|
|
554
|
+
|
|
555
|
+
- Detailed setup instructions for each build tool
|
|
556
|
+
- All configuration options explained
|
|
557
|
+
- Framework-specific examples (React, Vue, Angular, etc.)
|
|
558
|
+
- Troubleshooting guides
|
|
559
|
+
- Performance optimization tips
|
|
560
|
+
- Feature comparison matrix
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## �🚀 **Quick Start: Your First Conversion**
|
|
232
565
|
|
|
233
566
|
1. **Place your SVGs** in a directory (e.g., `./my-svgs`).
|
|
234
567
|
2. **Run the build command**:
|