The Vite convention does not apply
In a Vite project, UnoCSS is a bundler plugin andimport "uno.css" or virtual:uno.css
resolves to a generated virtual module. Extension.js builds with Rspack, and the UnoCSS
webpack plugin does not resolve that module there. A project that imports uno.css fails
with Can't resolve 'uno.css'.
Use the PostCSS plugin instead. It replaces an @unocss; directive inside a real CSS file
with the generated styles, so there is no virtual module to resolve.
Installation
Configuration
Createpostcss.config.mjs at the project root:
uno.config.ts next to it. The content.filesystem globs tell UnoCSS which files
to scan for class names, because no bundler plugin feeds it the module graph here:
Usage
Create a stylesheet that carries the directive. UnoCSS replaces it with the generated CSS:content_scripts/.
Verify
dist/chromium and look for the classes
that your markup uses. If the file holds no utility rules, the content.filesystem globs do not
cover the file that uses them.
Best practices
- Keep the directive stylesheet small. Global resets and tokens belong in a separate file.
- Scope the
content.filesystemglobs to source folders. A glob that reachesnode_modulesordistslows every build down. - Import the directive stylesheet once per entry, not once per component.
Next steps
- PostCSS: detection rules and the configuration files that Extension.js reads.
- Tailwind CSS: the same pipeline with Tailwind.
- CSS: how page and content-script styles are emitted.

