mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(kit): auto-detect mode
from filePath
for addComponent
(#24835)
This commit is contained in:
parent
f5a44fb20a
commit
fa3a83924e
@ -31,6 +31,11 @@ export async function addComponent (opts: AddComponentOptions) {
|
|||||||
await assertNuxtCompatibility({ nuxt: '>=2.13' }, nuxt)
|
await assertNuxtCompatibility({ nuxt: '>=2.13' }, nuxt)
|
||||||
nuxt.options.components = nuxt.options.components || []
|
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
|
// Apply defaults
|
||||||
const component: Component = {
|
const component: Component = {
|
||||||
export: opts.export || 'default',
|
export: opts.export || 'default',
|
||||||
|
Loading…
Reference in New Issue
Block a user