Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): add #components alias to tsconfig #6634

Merged
merged 2 commits into from
Aug 15, 2022
Merged
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
5 changes: 3 additions & 2 deletions packages/nuxt/src/components/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { statSync } from 'node:fs'
import { resolve } from 'pathe'
import { relative, resolve } from 'pathe'
import { defineNuxtModule, resolveAlias, addTemplate, addPluginTemplate } from '@nuxt/kit'
import type { Component, ComponentsDir, ComponentsOptions } from '@nuxt/schema'
import { componentsPluginTemplate, componentsTemplate, componentsTypeTemplate } from './templates'
Expand Down Expand Up @@ -137,7 +137,8 @@ export default defineNuxtModule<ComponentsOptions>({
context.components = newComponents
})

nuxt.hook('prepare:types', ({ references }) => {
nuxt.hook('prepare:types', ({ references, tsConfig }) => {
tsConfig.compilerOptions!.paths['#components'] = [relative(nuxt.options.rootDir, resolve(nuxt.options.buildDir, 'components'))]
references.push({ path: resolve(nuxt.options.buildDir, 'components.d.ts') })
})

Expand Down