Skip to content

Commit d472881

Browse files
committed
fix(vite): ensure angular tsconfig prefers .app.json and falls back to no suffix
1 parent 8c57189 commit d472881

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/vite/configuration/angular.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { mergeConfig, type UserConfig, type Plugin } from 'vite';
22
import path from 'path';
3+
import fs from 'node:fs';
34
import { createRequire } from 'node:module';
45
import angular from '@analogjs/vite-plugin-angular';
56
import { angularLinkerVitePlugin, angularLinkerVitePluginPost } from '../helpers/angular/angular-linker.js';
@@ -108,6 +109,14 @@ const cliFlags = getCliFlags();
108109
const isDevEnv = process.env.NODE_ENV !== 'production';
109110
const hmrActive = isDevEnv && !!cliFlags.hmr;
110111

112+
const projectRoot = process.cwd();
113+
const tsConfigAppPath = path.resolve(projectRoot, 'tsconfig.app.json');
114+
const tsConfigPath = path.resolve(projectRoot, 'tsconfig.json');
115+
let tsConfig = tsConfigAppPath;
116+
if (!fs.existsSync(tsConfigAppPath) && fs.existsSync(tsConfigPath)) {
117+
tsConfig = tsConfigPath;
118+
}
119+
111120
const plugins = [
112121
// Allow external html template changes to trigger hot reload: Make .ts files depend on their .html templates
113122
{
@@ -132,6 +141,7 @@ const plugins = [
132141
// angularRollupLinker(process.cwd()),
133142
angular({
134143
liveReload: false, // Disable live reload in favor of HMR
144+
tsconfig: tsConfig,
135145
}),
136146
// Post-phase linker to catch any declarations introduced after other transforms (including project code)
137147
angularLinkerVitePluginPost(process.cwd()),

0 commit comments

Comments
 (0)