GUIDES

Rollup

Add Plumeria to a Rollup project, with one command or by hand.

examples/example-rollup shows how to use @plumeria/unplugin in Rollup.
The plugin compiles Plumeria styles into the CSS asset Rollup produces.

npx @plumeria/init detects Rollup and writes this setup for you; see @plumeria/init. The rest of this page is the same setup by hand.

Installation

Terminal
pnpm i -D @plumeria/unplugin

Usage

rollup.config.js
import plumeria from '@plumeria/unplugin';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import esbuild from 'rollup-plugin-esbuild';
import postcss from 'rollup-plugin-postcss';

export default {
  input: 'src/index.tsx',
  output: {
    dir: 'dist',
    format: 'esm',
  },
  plugins: [
    plumeria.rollup(),
    postcss({ extract: true }),
    resolve({ extensions: ['.js', '.jsx', '.ts', '.tsx'] }),
    commonjs(),
    replace({
      'process.env.NODE_ENV': JSON.stringify('development'),
      preventAssignment: true,
    }),
    esbuild({
      include: /\.[jt]sx?$/,
      sourceMap: false,
      minify: false,
      target: 'es2022',
      jsx: 'automatic',
    }),
  ],
};

plumeria.d.ts

@plumeria/core ships no prop declaration of its own, so name the styling prop your project compiles with.

For the default name (sx), reference the declaration that ships with the package, in src/ when the project has one or at the application root otherwise:

plumeria.d.ts
/// <reference types="@plumeria/core/sx" />

If you set a custom styleProp (such as 'classStyle'), declare that name instead, and keep it the same as the one passed to the plugin; see Declaring the styling prop.

Edit on GitHub