bun-lightningcss
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

bun-lightningcss

Lightning CSS plugin for Bun with full support for class composition.

Install

bun install -d bun-lightningcss

Usage

import lightningcss from 'bun-lightningcss'

await Bun.build({
  entrypoints: ['./index.tsx'],
  outdir: './dist',
  plugins: [lightningcss()],
})

Say you have a app.module.css file...

.bg-indigo {
  background: indigo;
}

.container {
  /* https://lightningcss.dev/css-modules.html#class-composition */
  composes: bg-indigo;
  color: white;
}

Import and use it like so

import styles from './app.module.css'

export default function App() {
  return (
    <div className={styles.container}>
      Hello, Bun!
    </div>
  )
}

TypeScript Shim

Add the following to your .d.ts file:

declare module '*.module.css' {
  const styles: {
    readonly [key: string]: string
  }
  export default styles
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i bun-lightningcss

Weekly Downloads

593

Version

0.2.0

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • wobsoriano