diff --git a/packages/kit/src/components.ts b/packages/kit/src/components.ts index 365bf514af..26b8ddf140 100644 --- a/packages/kit/src/components.ts +++ b/packages/kit/src/components.ts @@ -31,6 +31,11 @@ export async function addComponent (opts: AddComponentOptions) { await assertNuxtCompatibility({ nuxt: '>=2.13' }, nuxt) nuxt.options.components = nuxt.options.components || [] + if (!opts.mode) { + const [, mode = 'all'] = opts.filePath.match(/\.(server|client)(\.\w+)*$/) || [] + opts.mode = mode as 'all' | 'client' | 'server' + } + // Apply defaults const component: Component = { export: opts.export || 'default',