fix(module): support nuxt-nightly (#3996)

This commit is contained in:
Daniel Roe
2025-04-28 09:43:22 +01:00
committed by Benjamin Canac
parent ac4c1946ec
commit bc0a296f9d

View File

@@ -6,6 +6,7 @@ import type { Resolver } from '@nuxt/kit'
import type { ModuleOptions } from './module' import type { ModuleOptions } from './module'
import * as theme from './theme' import * as theme from './theme'
import colors from 'tailwindcss/colors' import colors from 'tailwindcss/colors'
import { genExport } from 'knitwork'
export function buildTemplates(options: ModuleOptions) { export function buildTemplates(options: ModuleOptions) {
return Object.entries(theme).reduce((acc, [key, component]) => { return Object.entries(theme).reduce((acc, [key, component]) => {
@@ -182,9 +183,9 @@ export {}
filename: 'ui-image-component.ts', filename: 'ui-image-component.ts',
write: true, write: true,
getContents: ({ app }) => { getContents: ({ app }) => {
const image = app?.components?.find(c => c.pascalName === 'NuxtImg' && !c.filePath.includes('nuxt/dist/app')) const image = app?.components?.find(c => c.pascalName === 'NuxtImg' && !/nuxt(?:-nightly)?\/dist\/app/.test(c.filePath))
return image ? `export { default } from "${image.filePath}"` : 'export default "img"' return image ? genExport(image.filePath, [{ name: image.export, as: 'default' }]) : 'export default "img"'
} }
}) })