diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index aef60133d0..7a6890bf93 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -68,7 +68,7 @@ export const clientPluginTemplate: NuxtTemplate = { const imports: string[] = [] for (const plugin of clientPlugins) { const path = relative(ctx.nuxt.options.rootDir, plugin.src) - const variable = genSafeVariableName(filename(plugin.src)).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) + const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) exports.push(variable) imports.push(genImport(plugin.src, variable)) } @@ -88,7 +88,7 @@ export const serverPluginTemplate: NuxtTemplate = { const imports: string[] = [] for (const plugin of serverPlugins) { const path = relative(ctx.nuxt.options.rootDir, plugin.src) - const variable = genSafeVariableName(filename(path)).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) + const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path) exports.push(variable) imports.push(genImport(plugin.src, variable)) }