Skip to content

Commit 0616758

Browse files
committed
feat: support provider: none, close #393
1 parent 2ff1d7b commit 0616758

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ export default defineNuxtConfig({
223223
})
224224
```
225225

226+
Or if you want to disable the dynamic icon fetching completely and only use icons from the [client bundle](#client-bundle), you can set `provider: 'none'`:
227+
228+
```ts
229+
export default defineNuxtConfig({
230+
icon: {
231+
provider: 'none',
232+
clientBundle: {
233+
scan: true,
234+
// ...or other bundle options
235+
},
236+
}
237+
})
238+
```
239+
226240
### Case Sensitive Custom Collections
227241

228242
Before `v1.10`, due to the limitation of Iconify's previous convention, all custom icons were normalized to `kebab-case` with a warning. Thanks to the updates on Iconify side, starting from `v1.10`, you can opt-in to use case-sensitive custom collections and by pass the normalization.

playground/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default defineNuxtConfig({
6464
},
6565
],
6666
serverBundle: 'remote',
67+
// provider: 'none',
6768
fallbackToApi: 'server-only',
6869
// serverBundle: {
6970
// externalizeIconsJson: true,

src/runtime/plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export default defineNuxtPlugin({
2222
resources.push(options.iconifyApiEndpoint!)
2323
}
2424
}
25+
else if (options.provider === 'none') {
26+
// Provide a no-op fetch function to prevent Iconify from fetching icons
27+
_api.setFetch(() => Promise.resolve(new Response()))
28+
}
2529
else {
2630
resources.push(options.iconifyApiEndpoint!)
2731
}

src/schema-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ export interface NuxtIconRuntimeOptions {
9999
*
100100
* - `server` - Fetch icons with a server handler
101101
* - `iconify` - Fetch icons with Iconify API, purely client-side
102+
* - `none` - Do not fetch icons (use bundled icons only)
102103
*
103104
* `server` by default; `iconify` when `ssr: false`
104105
*
105-
*
106-
* @enum server,iconify
106+
* @enum server,iconify,none
107107
*/
108-
provider: 'server' | 'iconify' | undefined
108+
provider: 'server' | 'iconify' | 'none' | undefined
109109

110110
/**
111111
* Iconify API Endpoint URL

src/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ export const schema = {
112112
'',
113113
'- `server` - Fetch icons with a server handler',
114114
'- `iconify` - Fetch icons with Iconify API, purely client-side',
115+
'- `none` - Do not fetch icons (use client bundle only)',
115116
'',
116117
'`server` by default; `iconify` when `ssr: false`',
117118
].join('\n'),
118-
enum: ['server', 'iconify'],
119+
enum: ['server', 'iconify', 'none'],
119120
tags: ['@studioIcon material-symbols:cloud'],
120121
type: '"server" | "iconify" | undefined',
121122
},

0 commit comments

Comments
 (0)