A plugin for esbuild that enables SCSS and CSS Modules support, allowing you to import .scss or .module.scss files and obtain CSS module class name mappings. Currently at version 1.1.1, it is actively maintained with a low release cadence. It offers features like CSS injection and minification (via cssnano) and supports esbuild's watch mode. Compared to alternatives like esbuild-css-modules-plugin, this one directly integrates SCSS compilation without needing additional loaders or plugins. Ships TypeScript types.
npm install esbuild-scss-modules-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal setup showing how to use the plugin with esbuild, enabling CSS module support for .scss files and injecting styles into the bundle.
Use a separate esbuild CSS plugin for .css files or rename them to .scss.
Set inject: true to automatically inject CSS into JS bundle, or use the cssCallback to handle CSS.
Install cssnano: npm install cssnano@~5.0.6
Refer to the source file index.ts for all available options.
Install cssnano as a dev dependency: npm install --save-dev cssnano@~5.0.6
Use named import: import { ScssModulesPlugin } from 'esbuild-scss-modules-plugin'Add the plugin to the plugins array and ensure entry points import .scss files.