@nitedani/vite-plugin-compiled-react
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

vite-plugin-compiled-react

Vite plugin for https://github.com/atlassian-labs/compiled

The compiled.css files are temporarily created in the source directory, then removed after build. This way, the Vite css processing pipeline, postcss is applied to the extracted styles. For example, using Mantine:

input
css={{ color: "light-dark(green,red)"}}

output
._syaz1602{color:green}[data-mantine-color-scheme=dark]
._syaz1602{color:red}

Usage:

import { compiled } from "@nitedani/vite-plugin-compiled-react";

export default defineConfig({
  plugins: [react(), compiled({ extract: true })],
});
const Component = () => (
  <div
    css={{
      color: "red",
      ":hover": {
        color: "blue",
      },
    }}
  >
   Hello
  </div>
);

Typescript:

// types.d.ts
import { CssFunction } from "@compiled/react";
export { };
declare module "react" {
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
    // extends React's HTMLAttributes
    css?: CssFunction | CssFunction[]
  }
}

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

0

Version

0.0.9

License

MIT

Unpacked Size

6.24 kB

Total Files

4

Last publish

Collaborators

  • nitedani