Skip to content

Commit 9a28a18

Browse files
committed
chore: up
1 parent a036e57 commit 9a28a18

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

vite.config.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@ import { vocs } from 'vocs/vite'
55

66
// https://vite.dev/config/
77
export default defineConfig({
8-
plugins: [vocs(), react(), tempoNode()],
9-
ssr: {
10-
noExternal: ['vocs > @iconify-json/lucide', 'vocs > @iconify-json/simple-icons'],
11-
},
8+
plugins: [vocs(), react(), tempoNode(), patchIconifyImports()],
129
})
1310

11+
function patchIconifyImports(): Plugin {
12+
return {
13+
name: 'patch-iconify-imports',
14+
enforce: 'pre',
15+
transform(code, id) {
16+
if (!id.includes('icons') || !code.includes('@vite-ignore')) return
17+
18+
return code.replace(
19+
/await import\(\s*\/\*\s*@vite-ignore\s*\*\/\s*`@iconify-json\/\$\{collection\}`\s*\)/g,
20+
`(collection === 'lucide' ? await import('@iconify-json/lucide') : collection === 'simple-icons' ? await import('@iconify-json/simple-icons') : await Promise.reject(new Error('Unknown collection')))`,
21+
)
22+
},
23+
}
24+
}
25+
1426
function tempoNode(): Plugin {
1527
return {
1628
name: 'tempo-node',

0 commit comments

Comments
 (0)