Skip to content

Commit 641e9f2

Browse files
committed
Revert "[feat] improve custom icon build script with TypeScript and error handling (#5202)"
This reverts commit 7d6e252.
1 parent 74b61ec commit 641e9f2

File tree

6 files changed

+34
-125
lines changed

6 files changed

+34
-125
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ The project supports three types of icons, all with automatic imports (no manual
265265
2. **Iconify Icons** - 200,000+ icons from various libraries: `<i-lucide:settings />`, `<i-mdi:folder />`
266266
3. **Custom Icons** - Your own SVG icons: `<i-comfy:workflow />`
267267

268-
Icons are powered by the unplugin-icons system, which automatically discovers and imports icons as Vue components. Custom icons are stored in `src/assets/icons/custom/` and processed by `build/customIconCollection.ts` with automatic validation.
268+
Icons are powered by the unplugin-icons system, which automatically discovers and imports icons as Vue components. Custom icons are stored in `src/assets/icons/custom/`.
269269

270270
For detailed instructions and code examples, see [src/assets/icons/README.md](src/assets/icons/README.md).
271271

build/customIconCollection.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readFileSync, readdirSync } from 'fs'
2+
import { join } from 'path'
3+
import { dirname } from 'path'
4+
import { fileURLToPath } from 'url'
5+
6+
const fileName = fileURLToPath(import.meta.url)
7+
const dirName = dirname(fileName)
8+
const customIconsPath = join(dirName, '..', 'src', 'assets', 'icons', 'custom')
9+
10+
// Create an Iconify collection for custom icons
11+
export const iconCollection = {
12+
prefix: 'comfy',
13+
icons: {},
14+
width: 16,
15+
height: 16
16+
}
17+
18+
// Read all SVG files from the custom icons directory
19+
const files = readdirSync(customIconsPath)
20+
files.forEach((file) => {
21+
if (file.endsWith('.svg')) {
22+
const name = file.replace('.svg', '')
23+
const content = readFileSync(join(customIconsPath, file), 'utf-8')
24+
25+
iconCollection.icons[name] = {
26+
body: content
27+
}
28+
}
29+
})

build/customIconCollection.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/icons/README.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -247,29 +247,9 @@ Icons are automatically imported using `unplugin-icons` - no manual imports need
247247

248248
### Configuration
249249

250-
The icon system has two layers:
251-
252-
1. **Build-time Processing** (`build/customIconCollection.ts`):
253-
- Scans `src/assets/icons/custom/` for SVG files
254-
- Validates SVG content and structure
255-
- Creates Iconify collection for Tailwind CSS
256-
- Provides error handling for malformed files
257-
258-
2. **Vite Runtime** (`vite.config.mts`):
259-
- Enables direct SVG import as Vue components
260-
- Supports dynamic icon loading
250+
The icon system is configured in `vite.config.mts`:
261251

262252
```typescript
263-
// Build script creates Iconify collection
264-
export const iconCollection: IconifyCollection = {
265-
prefix: 'comfy',
266-
icons: {
267-
'workflow': { body: '<svg>...</svg>' },
268-
'node': { body: '<svg>...</svg>' }
269-
}
270-
}
271-
272-
// Vite configuration for component-based usage
273253
Icons({
274254
compiler: 'vue3',
275255
customCollections: {
@@ -291,9 +271,8 @@ Icons are fully typed. If TypeScript doesn't recognize a new custom icon:
291271
### Icon Not Showing
292272
1. **Check filename**: Must be kebab-case without special characters
293273
2. **Restart dev server**: Required after adding new icons
294-
3. **Verify SVG**: Ensure it's valid SVG syntax (build script validates automatically)
274+
3. **Verify SVG**: Ensure it's valid SVG syntax
295275
4. **Check console**: Look for Vue component resolution errors
296-
5. **Build script errors**: Check console during build - malformed SVGs are logged but don't break builds
297276

298277
### Icon Wrong Color
299278
- Replace hardcoded colors with `currentColor`

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @type {import('tailwindcss').Config} */
22
import { addDynamicIconSelectors } from '@iconify/tailwind'
33

4-
import { iconCollection } from './build/customIconCollection.ts'
4+
import { iconCollection } from './build/customIconCollection.js'
55

66
export default {
77
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],

0 commit comments

Comments
 (0)