esbuild-plugin-auto-css-modules
Automatically import styles filename mark CSS modules. After adding the flag, the build tool can distinguish whether to enable css Modules
Install
npm i esbuild-plugin-auto-css-modules -D
Usage
import { build } from 'esbuild'
import { autoCssModules } from 'esbuild-plugin-auto-css-modules'
build({
entryPoints: ['src/index.js'],
bundle: true,
outfile: 'dist/index.js',
plugins: [autoCssModules()],
}).catch(() => process.exit(1))
// before
import styles from './index.css';
// after
import styles from './index.css?modules';
Options
type Options = {
filter?: RegExp; // default: /\.([tj]sx?)$/
flag?: string; // default: modules
ignore?: RegExp | ((filename: string) => boolean); // default: null
}
Related
- esbuild-style-loader - esbuild style loader plugin