esbuild-css-modules-plugin
A esbuild plugin to bundle css modules into js(x)/ts(x).
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 ./test/test.js
for examples.
Install
npm i -D esbuild-css-modules-plugin
or
yarn add -D esbuild-css-modules-plugin
Usage
const esbuild = require('esbuild');
const cssModulesPlugin = require('esbuild-css-modules-plugin');
esbuild.build({
plugins: [
cssModulesPlugin({
inject: false,
localsConvention: 'camelCaseOnly',
generateScopedName: (name, filename, css) => string,
v2: true
})
]
});