WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ assets/my-icons
In your `nuxt.config.ts`, add an item in `icon.customCollections`:

```ts
import { createResolver } from "@nuxt/kit"

const { resolve } = createResolver(import.meta.url)

export default defineNuxtConfig({
modules: [
'@nuxt/icon'
Expand All @@ -165,7 +169,7 @@ export default defineNuxtConfig({
customCollections: [
{
prefix: 'my-icon',
dir: './assets/my-icons',
dir: resolve('./assets/my-icons'),
// if you want to include all the icons in nested directories:
// recursive: true,
},
Expand All @@ -174,6 +178,9 @@ export default defineNuxtConfig({
})
```

> [!NOTE]
> We use `createResolver` and `resolve()` to ensure paths work correctly both in regular projects and when your project is used as an extendable layer by other Nuxt projects. This ensures icon paths resolve relative to your project's directory rather than the consuming project's directory.

> [!NOTE]
> If you are running on Nuxt 4 with the new `app` directory, the assets directory is `'./app/assets/*'` instead of `'./assets/*'`.

Expand Down