JSPM

esbuild-plugin-simple-css-modules

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q53191F
  • License ISC

simple css module transformation without intermediate writes

Package Exports

  • esbuild-plugin-simple-css-modules
  • esbuild-plugin-simple-css-modules/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (esbuild-plugin-simple-css-modules) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Why another css-modules plugin?

Because I find the currently available plugins for css-modules quite convoluted and frankly slow because they utilize intermediate writes of the transformed css.

This plugin does not need intermediate writes and should thus be faster. Also it's quite a lot less code and less dependencies.

API

import * as Esbuild from "esbuild"
import cssmodules from "esbuild-plugin-simple-css-modules"

Esbuild.build({
  /* some build config */
    plugins: [cssmodules({
        transformClassName: (node) => {
            // node is an AST node, described here https://github.com/csstree/csstree/blob/bf05b963f85a08541c2991fa369f5bb613096db2/docs/ast.md
            return "my custom classname";
        }
    })},]
})