#4884·unocss

import inlineUnoCss from 'virtual:uno.css?inline' build error

Author: yunsiiCreated Aug 16, 2025Updated Sep 16, 2026

UnoCSS version

^66.4.2

Describe the bug

import inlineUnoCss from 'virtual:uno.css?inline' works in dev mode, it will throw error when building:

error during build:
[unocss:global:build:scan] Could not load /home/yuns/github/starter-monkey/src/components/inline-uno-css/__uno.css?inline (imported by src/components/inline-uno-css/index.tsx): [plugin unocss:global:build:scan] [unocss] layer "/home/yuns/github/starter-monkey/src/components/inline-uno-css/__uno.css?inline" is imported but not being resolved before, it might be an internal bug of UnoCSS
    at getRollupError (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
    at error (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
    at Object.error (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22029:20)
    at Object.load (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/@[email protected][email protected]_@[email protected][email protected][email protected]_/node_modules/@unocss/vite/dist/index.mjs:587:18)
    at Object.handler (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-CMEinpL-.js:34449:13)
    at file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22351:40
    at async PluginDriver.hookFirstAndGetPlugin (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22233:28)
    at async file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21237:33
    at async Queue.work (file:///home/yuns/github/starter-monkey/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22461:32)

I found the reason after investigation:

Should resolveLayer also use RESOLVED_ID_WITH_QUERY_RE?

Reproduction

https://github.com/yunsii/starter-monkey/tree/feat/reproduction01

System Info

No response

Validations