diff --git a/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap b/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap index 5c65c5dbb0d49..aa717d6f3ba12 100644 --- a/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap +++ b/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap @@ -49,7 +49,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = ` }, "typecheck": { "cache": true, - "command": "tsc --noEmit", + "command": "tsc --noEmit -p tsconfig.lib.json", "inputs": [ "production", "^production", diff --git a/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap b/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap index ad8da91a728b4..d41dfa2c2433d 100644 --- a/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap +++ b/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap @@ -49,7 +49,7 @@ exports[`@nx/vite/plugin with test node root project should create nodes - with }, "typecheck": { "cache": true, - "command": "tsc --noEmit", + "command": "tsc --noEmit -p tsconfig.lib.json", "inputs": [ "production", "^production", diff --git a/packages/vite/src/plugins/plugin.ts b/packages/vite/src/plugins/plugin.ts index 03cc61d914a87..3653abd62b8d6 100644 --- a/packages/vite/src/plugins/plugin.ts +++ b/packages/vite/src/plugins/plugin.ts @@ -206,18 +206,19 @@ async function buildViteTargets( } if (tsConfigFiles.length) { - const tsconfigToUse = tsConfigFiles.includes('tsconfig.lib.json') - ? 'tsconfig.lib.json' - : tsConfigFiles[0]; + const tsConfigToUse = + ['tsconfig.app.json', 'tsconfig.lib.json', 'tsconfig.json'].find((t) => + tsConfigFiles.includes(t) + ) ?? tsConfigFiles[0]; targets[options.typecheckTargetName] = { cache: true, inputs: ['production', '^production'], - command: 'tsc --noEmit', + command: `tsc --noEmit -p ${tsConfigToUse}`, options: { cwd: joinPathFragments(projectRoot) }, metadata: { description: `Run Typechecking`, help: { - command: `${pmc.exec} tsc --help -p ${tsconfigToUse}`, + command: `${pmc.exec} tsc --help -p ${tsConfigToUse}`, example: { options: { noEmit: true,