Skip to content

indooorsman/esbuild-css-modules-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

59b60e7 · Jan 7, 2025
Apr 12, 2024
Apr 12, 2024
Apr 25, 2024
Sep 11, 2023
Apr 13, 2022
Apr 25, 2024
Jun 12, 2023
Jan 7, 2025
Apr 25, 2024
Aug 27, 2023
Jan 7, 2025
Sep 4, 2023
Nov 29, 2023

Repository files navigation

esbuild-css-modules-plugin

npm version Test

A esbuild plugin to bundle css modules into js(x)/ts(x). Based on extremely fast Lightning CSS

Works both with bundle: false and bundle: true.

If build with bundle: false, xxx.modules.css will be transformed to xxx.modules.css.js.

See index.d.ts for all settings & ./test/test.js for examples.

Install

npm i -D esbuild-css-modules-plugin

or

yarn add -D esbuild-css-modules-plugin

Usage

import esbuild from 'esbuild';
import CssModulesPlugin from 'esbuild-css-modules-plugin';

esbuild.build({
  plugins: [
    CssModulesPlugin({
      // @see https://github.com/indooorsman/esbuild-css-modules-plugin/blob/main/index.d.ts for more details
      force: true,
      emitDeclarationFile: true,
      localsConvention: 'camelCaseOnly',
      namedExports: true,
      inject: false
    })
  ]
});