Skip to content

Commit 0234d34

Browse files
committed
fix(@angular/build): isolate Vite cache per build configuration in dev server
Running two ng serve instances for the same project with different configurations (e.g., different locales) caused "504 Outdated Optimize Dep" errors because both instances shared the same Vite optimizer cache directory. The fix includes the build configuration name in the Vite cache directory path, preventing cache conflicts between concurrent dev server instances. Closes angular#31700
1 parent 7fbc715 commit 0234d34

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/angular/build/src/builders/dev-server/vite

packages/angular/build/src/builders/dev-server/vite/server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ export async function setupServer(
162162
*/
163163
const preTransformRequests =
164164
externalMetadata.explicitBrowser.length === 0 && ssrMode === ServerSsrMode.NoSsr;
165-
const cacheDir = join(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
165+
// Include the build configuration in the cache path to prevent conflicts when running
166+
// multiple dev server instances with different configurations (e.g., different locales).
167+
const cacheDir = join(
168+
serverOptions.cacheOptions.path,
169+
serverOptions.buildTarget.project,
170+
'vite',
171+
serverOptions.buildTarget.configuration ?? '',
172+
);
166173

167174
const configuration: InlineConfig = {
168175
configFile: false,

0 commit comments

Comments
 (0)