# esbuild-css-modules-plugin **Repository Path**: zhangsyang/esbuild-css-modules-plugin ## Basic Information - **Project Name**: esbuild-css-modules-plugin - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-06 - **Last Updated**: 2021-12-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 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`](https://github.com/indooorsman/esbuild-css-modules-plugin/blob/master/test/test.js) for examples. ## Install ```shell npm i -D esbuild-css-modules-plugin ``` or ```shell yarn add -D esbuild-css-modules-plugin ``` ## Usage ```js const esbuild = require('esbuild'); const cssModulesPlugin = require('esbuild-css-modules-plugin'); esbuild.build({ plugins: [ cssModulesPlugin({ // optional. set to false to not inject generated CSS into , default is true. // could be a function with params content & digest (return a string of js code to inject to page), // e.g. // ``` // inject: (cssContent, digest) => `console.log("${cssContent}", "${digest}")` // ``` inject: false, localsConvention: 'camelCaseOnly', // optional. value could be one of 'camelCaseOnly', 'camelCase', 'dashes', 'dashesOnly', default is 'camelCaseOnly' generateScopedName: (name, filename, css) => string, // optional. v2: true // experimental. v2 can bundle images in css, note if set `v2` to true, the `inject` option will be ignored. and v2 only works with `bundle: true`. }) ] }); ```