diff --git a/e2e/vue/src/vue-legacy.test.ts b/e2e/vue/src/vue-legacy.test.ts new file mode 100644 index 00000000000000..4d92318a772b35 --- /dev/null +++ b/e2e/vue/src/vue-legacy.test.ts @@ -0,0 +1,45 @@ +import { cleanupProject, newProject, runCLI, uniq } from '@nx/e2e/utils'; + +describe('Vue Plugin (legacy)', () => { + let proj: string; + + beforeAll(() => { + proj = newProject({ + packages: ['@nx/vue'], + unsetProjectNameAndRootFormat: false, + }); + }); + + afterAll(() => cleanupProject()); + + it('should serve application in dev mode', async () => { + const app = uniq('app'); + + runCLI( + `generate @nx/vue:app ${app} --unitTestRunner=vitest --e2eTestRunner=playwright`, + { env: { NX_ADD_PLUGINS: 'false' } } + ); + let result = runCLI(`test ${app}`); + expect(result).toContain(`Successfully ran target test for project ${app}`); + + result = runCLI(`build ${app}`); + expect(result).toContain( + `Successfully ran target build for project ${app}` + ); + }, 200_000); + + it('should build library', async () => { + const lib = uniq('lib'); + + runCLI( + `generate @nx/vue:lib ${lib} --bundler=vite --unitTestRunner=vitest`, + + { env: { NX_ADD_PLUGINS: 'false' } } + ); + + const result = runCLI(`build ${lib}`); + expect(result).toContain( + `Successfully ran target build for project ${lib}` + ); + }); +}); diff --git a/packages/vite/src/executors/test/lib/utils.ts b/packages/vite/src/executors/test/lib/utils.ts index 7c1239b40c22ab..3b36c1f113ac0d 100644 --- a/packages/vite/src/executors/test/lib/utils.ts +++ b/packages/vite/src/executors/test/lib/utils.ts @@ -75,13 +75,10 @@ export async function getOptions( // This should not be needed as it's going to be set in vite.config.ts // but leaving it here in case someone did not migrate correctly root: resolved.config.root ?? root, - configFile: viteConfigPath, + config: viteConfigPath, }; - return { - resolvedOptions: mergeConfig(resolved?.config?.['test'] ?? {}, settings), - plugins: resolved?.config?.plugins, - }; + return mergeConfig(resolved?.config?.['test'] ?? {}, settings); } export function getOptionsAsArgv(obj: Record): string[] { diff --git a/packages/vite/src/executors/test/vitest.impl.ts b/packages/vite/src/executors/test/vitest.impl.ts index 18e618254549ff..4af8a33c0a1e07 100644 --- a/packages/vite/src/executors/test/vitest.impl.ts +++ b/packages/vite/src/executors/test/vitest.impl.ts @@ -19,7 +19,7 @@ export async function* vitestExecutor( // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future. const { startVitest } = await loadVitestDynamicImport(); - const { resolvedOptions, plugins } = + const resolvedOptions = (await getOptions(options, context, projectRoot)) ?? {}; const watch = resolvedOptions['watch'] === true; @@ -37,8 +37,7 @@ export async function* vitestExecutor( const ctx = await startVitest( resolvedOptions['mode'] ?? 'test', cliFilters, - resolvedOptions, - { plugins } + resolvedOptions ); let hasErrors = false; diff --git a/packages/vite/src/utils/options-utils.ts b/packages/vite/src/utils/options-utils.ts index 5656fecae3444b..9f4cd0b519e6e4 100644 --- a/packages/vite/src/utils/options-utils.ts +++ b/packages/vite/src/utils/options-utils.ts @@ -18,7 +18,7 @@ export function normalizeViteConfigFilePath( configFile?: string ): string | undefined { if (configFile) { - const normalized = joinPathFragments(configFile); + const normalized = joinPathFragments(contextRoot, configFile); if (!existsSync(normalized)) { throw new Error( `Could not find vite config at provided path "${normalized}".`