From 75f2f9efd431230f600a0bfb03d76bc5934a67d0 Mon Sep 17 00:00:00 2001 From: Yizack Rangel Date: Wed, 6 Aug 2025 18:25:21 +0200 Subject: [PATCH 1/2] fix: detect nuxt app using `.config` folder --- src/e2e/nuxt.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/e2e/nuxt.ts b/src/e2e/nuxt.ts index 7f8988687..b6fa72d07 100644 --- a/src/e2e/nuxt.ts +++ b/src/e2e/nuxt.ts @@ -14,6 +14,10 @@ const isNuxtApp = (dir: string) => { || existsSync(resolve(dir, 'nuxt.config.mjs')) || existsSync(resolve(dir, 'nuxt.config.cjs')) || existsSync(resolve(dir, 'nuxt.config.ts')) + || existsSync(resolve(dir, '.config', 'nuxt.js')) + || existsSync(resolve(dir, '.config', 'nuxt.mjs')) + || existsSync(resolve(dir, '.config', 'nuxt.cjs')) + || existsSync(resolve(dir, '.config', 'nuxt.ts')) ) } From d624817f80e9007598f850afecb5ec585fd7a00e Mon Sep 17 00:00:00 2001 From: Yizack Rangel Date: Wed, 6 Aug 2025 18:25:38 +0200 Subject: [PATCH 2/2] test: add dot config fixture --- examples/module/test/dot-config.test.ts | 26 +++++++++++++++++++ .../test/fixtures/dot-config/.config/nuxt.ts | 13 ++++++++++ .../module/test/fixtures/dot-config/app.vue | 7 +++++ .../test/fixtures/dot-config/package.json | 5 ++++ 4 files changed, 51 insertions(+) create mode 100644 examples/module/test/dot-config.test.ts create mode 100644 examples/module/test/fixtures/dot-config/.config/nuxt.ts create mode 100644 examples/module/test/fixtures/dot-config/app.vue create mode 100644 examples/module/test/fixtures/dot-config/package.json diff --git a/examples/module/test/dot-config.test.ts b/examples/module/test/dot-config.test.ts new file mode 100644 index 000000000..e4889ef48 --- /dev/null +++ b/examples/module/test/dot-config.test.ts @@ -0,0 +1,26 @@ +import { fileURLToPath } from 'node:url' +import { describe, expect, it } from 'vitest' +import { $fetch, setup, startServer } from '@nuxt/test-utils/e2e' + +describe('ssr', async () => { + await setup({ + rootDir: fileURLToPath(new URL('./fixtures/dot-config', import.meta.url)), + }) + + it('renders the index page', async () => { + // Get response to a server-rendered page with `$fetch`. + const html = await $fetch('/') + expect(html).toContain('
dot-config original value
') + }) + + it('changes runtime config and restarts', { timeout: 120000 }, async () => { + await startServer({ env: { NUXT_PUBLIC_MY_VALUE: 'overwritten by test!' } }) + + const html = await $fetch('/') + expect(html).toContain('
dot-config overwritten by test!
') + + await startServer() + const htmlRestored = await $fetch('/') + expect(htmlRestored).toContain('
dot-config original value
') + }) +}) diff --git a/examples/module/test/fixtures/dot-config/.config/nuxt.ts b/examples/module/test/fixtures/dot-config/.config/nuxt.ts new file mode 100644 index 000000000..37dfc832c --- /dev/null +++ b/examples/module/test/fixtures/dot-config/.config/nuxt.ts @@ -0,0 +1,13 @@ +import MyModule from '../../../../src/module' + +export default defineNuxtConfig({ + modules: [ + MyModule, + ], + runtimeConfig: { + public: { + myValue: 'original value', + }, + }, + compatibilityDate: '2024-04-03', +}) diff --git a/examples/module/test/fixtures/dot-config/app.vue b/examples/module/test/fixtures/dot-config/app.vue new file mode 100644 index 000000000..6b47d7a7d --- /dev/null +++ b/examples/module/test/fixtures/dot-config/app.vue @@ -0,0 +1,7 @@ + + + diff --git a/examples/module/test/fixtures/dot-config/package.json b/examples/module/test/fixtures/dot-config/package.json new file mode 100644 index 000000000..3503431ee --- /dev/null +++ b/examples/module/test/fixtures/dot-config/package.json @@ -0,0 +1,5 @@ +{ + "private": true, + "name": "example-module-dot-config-fixture", + "type": "module" +}