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,
filter: /\.modules?\.css$/i
cssModulesOption: {
},
v2: true,
v2CssModulesOption: {
dashedIndents: false,
pattern: `custom-prefix_[local]_[hash]`
}
})
]
});