You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nitro/vite will break down unocss in tanstack start RC #3596
bugSomething isn't working (PRs; issues use the Bug type)needs reproductionNeeds a minimal reproduction to move forwardtanstackReported from or affects TanStack Startvitenitro/vite plugin and Vite builder
changed the title [-]`nitro/vite` will break down unocss in tanstack RC[/-][+]`nitro/vite` will break down unocss in `tanstack start RC`[/+]on Sep 28, 2025
asyncconfigResolved(config){constdistDirs=[resolve(config.root,config.build.outDir),]// for Vite lib more with rollupOptions.output, #2231if(config.build.rollupOptions.output){constoutputOptions=config.build.rollupOptions.outputconstoutputDirs=Array.isArray(outputOptions)
? outputOptions.map(option=>option.dir).filter(Boolean)asstring[]
: outputOptions.dir
? [outputOptions.dir]
: []outputDirs.forEach((dir)=>{distDirs.push(dir)if(!isAbsolute(dir))distDirs.push(resolve(config.root,dir))})}constcssPostPlugin=config.plugins.find(i=>i.name==='vite:css-post')asPlugin|undefinedconstcssPlugin=config.plugins.find(i=>i.name==='vite:css')asPlugin|undefinedif(cssPostPlugin)distDirs.forEach(dir=>cssPostPlugins.set(dir,cssPostPlugin))if(cssPlugin)distDirs.forEach(dir=>cssPlugins.set(dir,cssPlugin))awaitready},
nitro/vite use a custom viteserver to build file, but the unocss just read the user's vite.config. So when it scan the file, it will not find the right path.
So to fix it issue the easy way is that we can let unocss/vite know nitro output path. Just add the build.outdir filed. But I will not effect the nitro.
But I think it's a problem about nitro working with all other vite plugins. When we use nitro/vite, the development servert & the builder is not using a same config. What do you think about that ? @pi0
We can explicitly point out the differences in configuration between nitro/vite and other Vite plugins in the document to help users understand. Currently, considering that this will not affect the core functions of nitro, it is recommended that no changes be made for the time being.
Basically patched @unocss/[email protected]/dist/index.mjs and added Nitro's .output/public and node_modules/.nitro/vite/services/ssr directories to the CSS plugin maps alongside the existing distDirs.
Root cause confirmed: Nitro sets build.outDir per Vite environment, so the top-level config that other plugins read in configResolved still says dist while the client build writes to .output/public — UnoCSS therefore never sees Nitro's output.
Until Nitro sets a root-level default, adding build: { outDir: ".output/public" } to vite.config.ts works around it without patching UnoCSS: the client build already writes there, so nothing actually moves. Note this only covers the client build; the SSR service builds into node_modules/.nitro/vite/services/ssr, which no single root-level value can cover.
Posted by an AI triage agent on behalf of a maintainer.
bugSomething isn't working (PRs; issues use the Bug type)needs reproductionNeeds a minimal reproduction to move forwardtanstackReported from or affects TanStack Startvitenitro/vite plugin and Vite builder
Activity
[-]`nitro/vite` will break down unocss in tanstack RC[/-][+]`nitro/vite` will break down unocss in `tanstack start RC`[/+]pi0 commentedon Sep 28, 2025
Can you please share a minimal reproduction with nitro plugin only + unocss? (no tanstack start)
zouhangwithsweet commentedon Oct 9, 2025
Sorry I cannot make a reproduction successfully. But I think it has a relation with these codes:
https://github.com/unocss/unocss/blob/main/packages-integrations/vite/src/modes/global/build.ts#L127
nitro/viteuse a custom viteserver to build file, but the unocss just read the user's vite.config. So when it scan the file, it will not find the right path.https://github.com/nitrojs/nitro/blob/main/src/build/vite/build.ts#L10
zouhangwithsweet commentedon Oct 9, 2025
So to fix it issue the easy way is that we can let unocss/vite know nitro output path. Just add the
build.outdirfiled. But I will not effect the nitro.zouhangwithsweet commentedon Oct 9, 2025
But I think it's a problem about nitro working with all other vite plugins. When we use
nitro/vite, the development servert & the builder is not using a same config. What do you think about that ? @pi0pi0 commentedon Oct 9, 2025
Maybe we default
userConfig.build.outDirwhen not set by users?zouhangwithsweet commentedon Oct 10, 2025
We can explicitly point out the differences in configuration between nitro/vite and other Vite plugins in the document to help users understand. Currently, considering that this will not affect the core functions of nitro, it is recommended that no changes be made for the time being.
zouhangwithsweet commentedon Oct 10, 2025
I also notice that
nitro/vitehave differrent behavoir withviteorrolldown/vitegxres042 commentedon Oct 10, 2025
nitro/vitehadn't supportedrolldown-viteyetzouhangwithsweet commentedon Nov 11, 2025
[email protected]will break dev server down withtanstack start.node:internal/url:826 href = bindingUrl.parse(input, base, true); ^ TypeError: Invalid URL at new URL (node:internal/url:826:25)pi0 commentedon Nov 11, 2025
I have added a fix to [email protected] to this issue. You can update lockfile to get fix.
(keeping issue open, we should fix some more places in nitro to avoid similar issues in the future)
zouhangwithsweet commentedon Nov 12, 2025
nitrobuild will copynode_modulesinto server folder, but the packages's lost many files. Likedrizzle-orm, it lostsindex.jsbalabla.--- update ---
I can fix it with the options
noExternals: true, butnitrodefault value isfalsepi0 commentedon Nov 12, 2025
@zouhangwithsweet only used files will be traced. Did you get a runtime error for drizzle usage? (if yes it is a bug with nf3 integration)
zouhangwithsweet commentedon Nov 12, 2025
Yes, there is a runtime error.
cannot resolve drizzel-orm/index.js. Look likes a upstream bug.zouhangwithsweet commentedon Nov 12, 2025
I had updated
https://github.com/fisand/f3-app/tree/main/apps/web-tanstack, you can reproduce it easily.tommy141x commentedon Dec 26, 2025
I made this patch with Bun's patch system as a workaround to register Nitro v3's output directories with UnoCSS's CSS pipeline.
Basically patched
@unocss/[email protected]/dist/index.mjsand added Nitro's.output/publicandnode_modules/.nitro/vite/services/ssrdirectories to the CSS plugin maps alongside the existing distDirs.pi0x commentedon Sep 7, 2026
Root cause confirmed: Nitro sets
build.outDirper Vite environment, so the top-level config that other plugins read inconfigResolvedstill saysdistwhile the client build writes to.output/public— UnoCSS therefore never sees Nitro's output.Until Nitro sets a root-level default, adding
build: { outDir: ".output/public" }tovite.config.tsworks around it without patching UnoCSS: the client build already writes there, so nothing actually moves. Note this only covers the client build; the SSR service builds intonode_modules/.nitro/vite/services/ssr, which no single root-level value can cover.Posted by an AI triage agent on behalf of a maintainer.