Skip to content

esbuild-plugin-postcss

A CSS loader plugin for esbuild that uses PostCSS as preprocessor.

Install

sh
npm i -D @chialab/esbuild-plugin-postcss
sh
yarn add -D @chialab/esbuild-plugin-postcss
sh
pnpm add -D @chialab/esbuild-plugin-postcss

Usage

js
import postcssPlugin from '@chialab/esbuild-plugin-postcss';
import esbuild from 'esbuild';

await esbuild.build({
    plugins: [postcssPlugin()],
});

This plugin looks for a postcss configuration in the project and fallbacks to out custom postcss-preset-env.

Sass

The plugin automatically tries to load the @chialab/postcss-plugin-dart-sass when it processes .scss files. Please make sure to have installed the optional dependency in order to correctly transpiler Sass files:

sh
npm i -D @chialab/postcss-plugin-dart-sass
sh
yarn add -D @chialab/postcss-plugin-dart-sass
sh
pnpm add -D @chialab/postcss-plugin-dart-sass

Released under the MIT License.