@@ -21,10 +21,14 @@ export async function routes(
2121 flags : {
2222 config ?: string ;
2323 json ?: boolean ;
24+ mode ?: string ;
2425 } = { }
2526) : Promise < void > {
2627 let rootDirectory = reactRouterRoot ?? process . cwd ( ) ;
27- let configResult = await loadConfig ( { rootDirectory } ) ;
28+ let configResult = await loadConfig ( {
29+ rootDirectory,
30+ mode : flags . mode ?? "production" ,
31+ } ) ;
2832
2933 if ( ! configResult . ok ) {
3034 console . error ( colors . red ( configResult . error ) ) ;
@@ -81,6 +85,7 @@ export async function generateEntry(
8185 flags : {
8286 typescript ?: boolean ;
8387 config ?: string ;
88+ mode ?: string ;
8489 } = { }
8590) {
8691 // if no entry passed, attempt to create both
@@ -91,7 +96,10 @@ export async function generateEntry(
9196 }
9297
9398 let rootDirectory = reactRouterRoot ?? process . cwd ( ) ;
94- let configResult = await loadConfig ( { rootDirectory } ) ;
99+ let configResult = await loadConfig ( {
100+ rootDirectory,
101+ mode : flags . mode ?? "production" ,
102+ } ) ;
95103
96104 if ( ! configResult . ok ) {
97105 console . error ( colors . red ( configResult . error ) ) ;
@@ -198,17 +206,25 @@ async function createClientEntry(
198206 return contents ;
199207}
200208
201- export async function typegen ( root : string , flags : { watch : boolean } ) {
209+ export async function typegen (
210+ root : string ,
211+ flags : {
212+ watch : boolean ;
213+ mode ?: string ;
214+ }
215+ ) {
202216 root ??= process . cwd ( ) ;
203217
218+ let mode = flags . mode ?? "production" ;
219+
204220 if ( flags . watch ) {
205221 await preloadVite ( ) ;
206222 const vite = getVite ( ) ;
207223 const logger = vite . createLogger ( "info" , { prefix : "[react-router]" } ) ;
208224
209- await Typegen . watch ( root , { logger } ) ;
225+ await Typegen . watch ( root , { mode , logger } ) ;
210226 await new Promise ( ( ) => { } ) ; // keep alive
211227 return ;
212228 }
213- await Typegen . run ( root ) ;
229+ await Typegen . run ( root , { mode } ) ;
214230}
0 commit comments