diff --git a/README.md b/README.md index 3d60bedb..1de3cdf2 100644 --- a/README.md +++ b/README.md @@ -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' @@ -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, }, @@ -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/*'`.