1
+ import { getConfig } from '@tanstack/router-generator'
1
2
import { unpluginRouterGeneratorFactory } from './router-generator-plugin'
2
3
import { unpluginRouterCodeSplitterFactory } from './router-code-splitter-plugin'
3
4
import { unpluginRouterHmrFactory } from './router-hmr-plugin'
@@ -8,6 +9,9 @@ import type { UnpluginFactory } from 'unplugin'
8
9
export const unpluginRouterComposedFactory : UnpluginFactory <
9
10
Partial < Config > | undefined
10
11
> = ( options = { } , meta ) => {
12
+ const ROOT : string = process . cwd ( )
13
+ const userConfig = getConfig ( options , ROOT )
14
+
11
15
const getPlugin = ( pluginFactory : UnpluginFactory < Partial < Config > > ) => {
12
16
const plugin = pluginFactory ( options , meta )
13
17
if ( ! Array . isArray ( plugin ) ) {
@@ -21,16 +25,16 @@ export const unpluginRouterComposedFactory: UnpluginFactory<
21
25
const routeAutoImport = getPlugin ( unpluginRouteAutoImportFactory )
22
26
23
27
const result = [ ...routerGenerator ]
24
- if ( options . autoCodeSplitting ) {
28
+ if ( userConfig . autoCodeSplitting ) {
25
29
result . push ( ...routerCodeSplitter )
26
30
}
27
- if ( options . verboseFileRoutes === false ) {
31
+ if ( userConfig . verboseFileRoutes === false ) {
28
32
result . push ( ...routeAutoImport )
29
33
}
30
34
31
35
const isProduction = process . env . NODE_ENV === 'production'
32
36
33
- if ( ! isProduction && ! options . autoCodeSplitting ) {
37
+ if ( ! isProduction && ! userConfig . autoCodeSplitting ) {
34
38
const routerHmr = getPlugin ( unpluginRouterHmrFactory )
35
39
result . push ( ...routerHmr )
36
40
}
0 commit comments