fix(vite): resolve project-specific tsconfig before workspace fallback (#31423)
## Current Behavior The Nx Vite TsConfig paths plugin incorrectly resolves to workspace root tsconfig files instead of project-specific ones, causing path aliases like `@/contexts` to fail resolution. ## Expected Behavior The plugin should check for project-specific tsconfig files (`tsconfig.app.json`, `tsconfig.lib.json`, `tsconfig.json`) before falling back to workspace root configurations. ## Related Issue(s) Fixes #28945 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Coly010 <Coly010@users.noreply.github.com>
This commit is contained in:
parent
88c51965e6
commit
b97ee099c8
@ -20,6 +20,7 @@ import { Plugin } from 'vite';
|
|||||||
import { nxViteBuildCoordinationPlugin } from './nx-vite-build-coordination.plugin';
|
import { nxViteBuildCoordinationPlugin } from './nx-vite-build-coordination.plugin';
|
||||||
import { findFile } from '../src/utils/nx-tsconfig-paths-find-file';
|
import { findFile } from '../src/utils/nx-tsconfig-paths-find-file';
|
||||||
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||||
|
import { getProjectTsConfigPath } from '../src/utils/options-utils';
|
||||||
|
|
||||||
export interface nxViteTsPathsOptions {
|
export interface nxViteTsPathsOptions {
|
||||||
/**
|
/**
|
||||||
@ -210,12 +211,16 @@ export function nxViteTsPaths(options: nxViteTsPathsOptions = {}) {
|
|||||||
} as Plugin;
|
} as Plugin;
|
||||||
|
|
||||||
function getTsConfig(preferredTsConfigPath: string): string {
|
function getTsConfig(preferredTsConfigPath: string): string {
|
||||||
|
const projectTsConfigPath = getProjectTsConfigPath(projectRoot);
|
||||||
return [
|
return [
|
||||||
resolve(preferredTsConfigPath),
|
resolve(preferredTsConfigPath),
|
||||||
|
projectTsConfigPath ? resolve(projectTsConfigPath) : null,
|
||||||
resolve(join(workspaceRoot, 'tsconfig.base.json')),
|
resolve(join(workspaceRoot, 'tsconfig.base.json')),
|
||||||
resolve(join(workspaceRoot, 'tsconfig.json')),
|
resolve(join(workspaceRoot, 'tsconfig.json')),
|
||||||
resolve(join(workspaceRoot, 'jsconfig.json')),
|
resolve(join(workspaceRoot, 'jsconfig.json')),
|
||||||
].find((tsPath) => {
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.find((tsPath) => {
|
||||||
if (existsSync(tsPath)) {
|
if (existsSync(tsPath)) {
|
||||||
logIt('Found tsconfig at', tsPath);
|
logIt('Found tsconfig at', tsPath);
|
||||||
return tsPath;
|
return tsPath;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user