MCPcopy Index your code
hub / github.com/TanStack/router / config

Function config

packages/start-plugin-core/src/plugin.ts:109–361  ·  view source on GitHub ↗
(viteConfig, { command })

Source from the content-addressed store, hash-verified

107 name: 'tanstack-start-core:config',
108 enforce: 'pre',
109 async config(viteConfig, { command }) {
110 resolvedStartConfig.viteAppBase = viteConfig.base ?? '/'
111 if (!isFullUrl(resolvedStartConfig.viteAppBase)) {
112 resolvedStartConfig.viteAppBase = joinPaths([
113 '/',
114 viteConfig.base,
115 '/',
116 ])
117 }
118 const root = viteConfig.root || process.cwd()
119 resolvedStartConfig.root = root
120
121 const { startConfig } = getConfig()
122 if (startConfig.router.basepath === undefined) {
123 if (!isFullUrl(resolvedStartConfig.viteAppBase)) {
124 startConfig.router.basepath =
125 resolvedStartConfig.viteAppBase.replace(/^\/|\/$/g, '')
126 } else {
127 startConfig.router.basepath = '/'
128 }
129 } else {
130 if (command === 'serve' && !viteConfig.server?.middlewareMode) {
131 // when serving, we must ensure that router basepath and viteAppBase are aligned
132 if (
133 !joinPaths(['/', startConfig.router.basepath, '/']).startsWith(
134 joinPaths(['/', resolvedStartConfig.viteAppBase, '/']),
135 )
136 ) {
137 // The router basepath and vite base are misaligned.
138 // Instead of erroring, we install a dev-server middleware that
139 // rewrites incoming request URLs to prepend the vite base prefix.
140 // This allows users to have e.g. base: '/_ui/' for asset URLs
141 // while keeping router basepath at '/' for page navigation.
142 needsDevBaseRewrite = true
143 }
144 }
145 }
146
147 const TSS_SERVER_FN_BASE = joinPaths([
148 '/',
149 startConfig.router.basepath,
150 startConfig.serverFns.base,
151 '/',
152 ])
153 const resolvedSrcDirectory = join(root, startConfig.srcDirectory)
154 resolvedStartConfig.srcDirectory = resolvedSrcDirectory
155
156 const startFilePath = resolveEntry({
157 type: 'start entry',
158 configuredEntry: startConfig.start.entry,
159 defaultEntry: 'start',
160 resolvedSrcDirectory,
161 required: false,
162 })
163 resolvedStartConfig.startFilePath = startFilePath
164
165 const routerFilePath = resolveEntry({
166 type: 'router entry',

Callers 1

vite.config.tsFile · 0.50

Calls 10

joinPathsFunction · 0.90
resolveEntryFunction · 0.90
getClientOutputDirectoryFunction · 0.90
getServerOutputDirectoryFunction · 0.90
joinFunction · 0.85
defineReplaceEnvFunction · 0.85
startsWithMethod · 0.80
isFullUrlFunction · 0.70
getConfigFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected