Skip to content

Commit

Permalink
fix: don't rely on presence of @nuxt/ui-templates (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 3, 2024
1 parent f5e4201 commit 5b8f450
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
addServerHandler,
createResolver,
defineNuxtModule,
resolveModule,
tryResolveModule,
addImportsDir,
addTemplate
} from '@nuxt/kit'
Expand Down Expand Up @@ -111,13 +111,16 @@ export default defineNuxtModule<ModuleOptions>({
let components: Component[] = []
let metaSources: NuxtComponentMeta = {}

const uiTemplatesPath = await tryResolveModule('@nuxt/ui-templates')
nuxt.hook('components:dirs', (dirs) => {
componentDirs = [
...componentDirs,
...dirs,
{ path: resolveModule('nuxt').replace('/index.mjs', '/app') },
{ path: resolveModule('@nuxt/ui-templates').replace('/index.mjs', '/templates') }
{ path: nuxt.options.appDir }
]
if (uiTemplatesPath) {
componentDirs.push({ path: uiTemplatesPath.replace('/index.mjs', '/templates') })
}
parserOptions.componentDirs = componentDirs
})

Expand Down

0 comments on commit 5b8f450

Please sign in to comment.