Skip to content

Commit 4ad69f9

Browse files
Add route module chunk suffix to build output (remix-run#12906)
1 parent bfc2de7 commit 4ad69f9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from "es-module-lexer";
2323
import jsesc from "jsesc";
2424
import colors from "picocolors";
25+
import kebabCase from "lodash/kebabCase";
2526

2627
import * as Typegen from "../typegen";
2728
import { type RouteManifestEntry, type RouteManifest } from "../config/routes";
@@ -1024,6 +1025,21 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
10241025
rollupOptions: {
10251026
...baseRollupOptions,
10261027
preserveEntrySignatures: "exports-only",
1028+
output: {
1029+
entryFileNames({ moduleIds }) {
1030+
let routeChunkModuleId =
1031+
moduleIds.find(isRouteChunkModuleId);
1032+
let routeChunkName = routeChunkModuleId
1033+
? getRouteChunkNameFromModuleId(
1034+
routeChunkModuleId
1035+
)
1036+
: null;
1037+
let routeChunkSuffix = routeChunkName
1038+
? `-${kebabCase(routeChunkName)}`
1039+
: "";
1040+
return `assets/[name]${routeChunkSuffix}-[hash].js`;
1041+
},
1042+
},
10271043
input: [
10281044
ctx.entryClientFilePath,
10291045
...Object.values(

0 commit comments

Comments
 (0)