Skip to content

Commit 7456acc

Browse files
committed
Merge branch 'main' into enhanced-logs-flag
2 parents d37aa62 + c82dd69 commit 7456acc

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/vite/file.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type WriteFileData = {
1818
meta: boolean
1919
links: boolean
2020
}
21+
appDir: string
2122
}
2223
const defaultGenerationOrder: Exclude<Generator, "dependencies">[] = [
2324
"links",
@@ -32,15 +33,15 @@ const defaultGenerationOrder: Exclude<Generator, "dependencies">[] = [
3233
"errorBoundary",
3334
"revalidate",
3435
]
35-
export const handleWriteFile = async ({ path, options, openInEditor }: WriteFileData) => {
36+
export const handleWriteFile = async ({ path, options, openInEditor, appDir }: WriteFileData) => {
3637
const generatorOptions = Object.entries(options)
3738
.map(([key, value]) => {
3839
if (value) {
3940
return { key }
4041
}
4142
})
4243
.filter(Boolean) as unknown as { key: Exclude<Generator, "dependencies"> }[]
43-
let outputFile = `${resolve("app", "routes", path)}`
44+
let outputFile = `${resolve(appDir, "routes", path)}`
4445
const extensions = [".tsx", ".jsx", ".ts", ".js"]
4546
if (!extensions.some((ext) => outputFile.endsWith(ext))) {
4647
outputFile = `${outputFile}.tsx`

src/vite/plugin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
107107
try {
108108
const path = await import("node:path")
109109
// Set the route config
110-
const routeConfigExport = (await runner.executeFile(path.join(process.cwd(), "./app/routes.ts"))).default
110+
const routeConfigExport = (await runner.executeFile(path.join(process.cwd(), appDir, "routes.ts"))).default
111111
const routeConfig = await routeConfigExport
112112
routesMap.set("routes", routeConfig)
113113

@@ -344,7 +344,7 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
344344
})
345345

346346
server.hot.on("open-source", (data: OpenSourceData) => handleOpenSource({ data, openInEditor, appDir }))
347-
server.hot.on("add-route", (data: WriteFileData) => handleWriteFile({ ...data, openInEditor }))
347+
server.hot.on("add-route", (data: WriteFileData) => handleWriteFile({ ...data, openInEditor, appDir }))
348348
}
349349
},
350350
},

0 commit comments

Comments
 (0)