An esbuild plugin for processing CSS, SASS, LESS, and STYLUS files. Version 1.6.3. It handles CSS modules via PostCSS, supports reading postcss.config.js, and extracts CSS by default. Preprocessors are not bundled; you install only what you need (sass, less, stylus). It ships TypeScript definitions and supports both ESM and CJS builds. Key differentiators: SSR-friendly (extract: false keeps CSS modules mapping), dynamic preprocessor imports, and built-in PostCSS integration without requiring additional configuration plugins.
npm install esbuild-style-pluginVerified import paths — ran on the pinned version, not inferred.
Basic esbuild build using esbuild-style-plugin with all options explicitly set, showing ESM import and TypeScript usage.
Run npm i -D sass (or less/stylus) for the preprocessor you need.
Remove cssnano from postcss.plugins; let esbuild handle minification.
Use an absolute path string instead of boolean true for clarity.
Set extract: true to output CSS files, or keep false for SSR and handle CSS injection server-side.
Install the preprocessor: npm i -D sass (or less, stylus)
Use 'import stylePlugin from 'esbuild-style-plugin'' instead of 'import { stylePlugin }'Install postcss: npm i -D postcss