11import { mergeConfig , type UserConfig , type Plugin } from 'vite' ;
22import path from 'path' ;
3+ import fs from 'node:fs' ;
34import { createRequire } from 'node:module' ;
45import angular from '@analogjs/vite-plugin-angular' ;
56import { angularLinkerVitePlugin , angularLinkerVitePluginPost } from '../helpers/angular/angular-linker.js' ;
@@ -108,6 +109,14 @@ const cliFlags = getCliFlags();
108109const isDevEnv = process . env . NODE_ENV !== 'production' ;
109110const 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+
111120const 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