Skip to content

Commit 2fbdefc

Browse files
committed
Fix assetsDir in entryFileNames with Vite Env API
1 parent 5a08b1e commit 2fbdefc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/rude-cobras-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
When `future.unstable_viteEnvironmentApi` is enabled, ensure that `build.assetsDir` in Vite config is respected when `environments.client.build.assetsDir` is not configured

packages/react-router-dev/vite/plugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,10 +3541,14 @@ export async function getEnvironmentOptionsResolvers(
35413541
let routeChunkSuffix = routeChunkName
35423542
? `-${kebabCase(routeChunkName)}`
35433543
: "";
3544-
return path.posix.join(
3544+
let assetsDir =
35453545
(ctx.reactRouterConfig.future.unstable_viteEnvironmentApi
35463546
? viteUserConfig?.environments?.client?.build?.assetsDir
3547-
: viteUserConfig?.build?.assetsDir) ?? "assets",
3547+
: null) ??
3548+
viteUserConfig?.build?.assetsDir ??
3549+
"assets";
3550+
return path.posix.join(
3551+
assetsDir,
35483552
`[name]${routeChunkSuffix}-[hash].js`
35493553
);
35503554
},

0 commit comments

Comments
 (0)