Supported bundlers
Esbuild

Usage with esbuild

Installation

# npm
npm i -D @wyw-in-js/esbuild
# yarn
yarn add --dev @wyw-in-js/esbuild
# pnpm
pnpm add -D @wyw-in-js/esbuild
# bun
bun add -d @wyw-in-js/esbuild

Configuration

import wyw from '@wyw-in-js/esbuild';
import esbuild from 'esbuild';
 
const prod = process.env.NODE_ENV === 'production';
 
esbuild
  .build({
    entryPoints: ['src/index.ts'],
    outdir: 'dist',
    bundle: true,
    minify: prod,
    plugins: [
      wyw({
        filter: /\.(js|jsx|ts|tsx)$/,
        sourceMap: prod,
      }),
    ],
  })
  .catch(() => process.exit(1));

Keeping CSS comments

Stylis strips CSS comments by default. To preserve them (for example, /*rtl:ignore*/), pass keepComments:

wyw({
  keepComments: true,
  // or keep only matching comments:
  // keepComments: /rtl:/,
});

Note: esbuild removes CSS comments when minify: true. Disable CSS minification if you need comments in the final output.