npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-compiled-react

v2.0.0

Published

Vite plugin for [Compiled](https://compiledcssinjs.com), the CSS-in-JS library: write the `css` prop on any element, get atomic CSS that Vite bundles and links like any other CSS. It works in client, SSR and React Server Components environments.

Readme

vite-plugin-compiled-react

Vite plugin for Compiled, the CSS-in-JS library: write the css prop on any element, get atomic CSS that Vite bundles and links like any other CSS. It works in client, SSR and React Server Components environments.

Install

npm i @compiled/react
npm i -D vite-plugin-compiled-react

Usage

// vite.config.js
import react from '@vitejs/plugin-react';
import { compiled } from 'vite-plugin-compiled-react';

export default {
  plugins: [react(), compiled()],
};
const Greeting = () => (
  <p css={{ color: 'red', ':hover': { color: 'blue' } }}>Hello</p>
);

The css prop works in .jsx and .tsx files without importing Compiled. Compiled's other APIs (css(), styled, cssMap, keyframes) are imported from @compiled/react as usual, in .js, .jsx, .ts and .tsx files.

Styles can use values imported from other modules, including through your string resolve.alias entries.

The css prop is typed on every HTML and SVG element once the plugin's types are part of your TypeScript program: either your vite.config.ts is, or add the plugin to compilerOptions.types:

{
  "compilerOptions": {
    "types": ["vite-plugin-compiled-react"]
  }
}

Options

compiled({
  extract: true,
  addComponentName: false,
  optimizeCss: true,
});
  • extract (default true): extract the styles into one stylesheet for the whole app, sorted in Compiled's order, which atomic CSS needs to cascade right. It goes through your PostCSS config, and every page links it, including in the server-rendered HTML. It also gets the rules of the .compiled.css files that packages such as Atlaskit ship already extracted, in place of their own <style> or stylesheet. A library build (build.lib) puts the rules in the library's own stylesheet, for example dist/my-lib.css. With build.cssCodeSplit: true, each stylesheet Vite splits out, for example dist/index.css, gets the rules of its own modules. In a library, the rules of different modules follow the order of their modules rather than Compiled's, since Vite gives plugins no way to sort a library's CSS before minifying it. With extract: false, Compiled's runtime inserts <style> elements while rendering instead. Pass { build: true, serve: false } to decide per command, for example when your framework doesn't link CSS in development. Server components always extract, since Compiled's runtime can't run in them.
  • addComponentName (default false): add the component name as a class name to styled components outside production.
  • optimizeCss (default true): minify the generated CSS rules.

Migrating from 1.x

  • Requires Vite 6.3 or later and @compiled/react 2. @vitejs/plugin-react is no longer a peer dependency: the plugin compiles in its own transform.
  • extract defaults to true. Pass extract: false to keep the runtime.
  • Extracted styles go into one stylesheet linked on every page, not a stylesheet per module.
  • The cache and onIncludedFiles options are removed.
  • The plugin no longer adds @compiled/react to ssr.noExternal.
  • In a build, the files the stylesheet's URLs point to are always emitted, never inlined under build.assetsInlineLimit, and their URLs get your base rather than going through experimental.renderBuiltUrl. To serve them from another host, set base to that host's URL.
  • A relative URL in a css prop resolves from the module that uses the styles, rather than from the project root. Styles shared across folders should use an aliased or root-relative URL.