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.
npm i -D esbuild-css-modules-plugin
or
yarn add -D esbuild-css-modules-plugin
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
})
]
});