Skip to content

Automatically import styles filename mark CSS modules. After adding the flag, the build tool can distinguish whether to enable css Modules

Notifications You must be signed in to change notification settings

noyobo/esbuild-plugin-auto-css-modules

Repository files navigation

esbuild-plugin-auto-css-modules

npm version License: MIT issues PRs Welcome downloads Code Coverage Node.js CI

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

About

Automatically import styles filename mark CSS modules. After adding the flag, the build tool can distinguish whether to enable css Modules

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published