diff --git a/packages/nuxt/src/core/plugins/import-protection.ts b/packages/nuxt/src/core/plugins/import-protection.ts index 3826ff6b6b..2646b3dd78 100644 --- a/packages/nuxt/src/core/plugins/import-protection.ts +++ b/packages/nuxt/src/core/plugins/import-protection.ts @@ -15,7 +15,7 @@ interface ImportProtectionOptions { export const vueAppPatterns = (nuxt: Nuxt) => [ [/^(nuxt3|nuxt)$/, '`nuxt3`/`nuxt` cannot be imported directly. Instead, import runtime Nuxt composables from `#app` or `#imports`.'], - [/nuxt\.config/, 'Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module.'], + [/^((|~|~~|@|@@)\/)?nuxt\.config(\.|$)/, 'Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module.'], [/(^|node_modules\/)@vue\/composition-api/], ...nuxt.options.modules.filter(m => typeof m === 'string').map((m: string) => [new RegExp(`^${escapeRE(m)}$`), 'Importing directly from module entry points is not allowed.']),