Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vite-plugin-css-modules

wangzongming13.6kMIT0.0.1

vite projects to support Not .module.xxx can use css modules

vite, vite-plugin, vite-plugin-css-modules

readme

vite-plugin-css-modules

npm

Make all style files supported css module, not just xxx.module.xxx

Install

npm i vite-plugin-css-modules | yarn add vite-plugin-css-modules

Usage

import vitePluginCssModules from "vite-plugin-css-modules";

export default {
    plugins: [vitePluginCssModules()],
};

Options

precompilers [optional]

Precompiler configuration for various style files. Plug-in built-in less type file compilation configuration

eg: less

vitePluginCssModules({
    precompilers:[
        {
            regExp: /.(less)$/,
            // Self-handling compilation
            ompiler: async (code, file) => {
                const cssCode = (
                    await nodeLess.render(code, {
                        syncImport: true,
                        javascriptEnabled: true,
                    })
                ).css;
                return cssCode
            }
        }
    ]
}),

postcssPlugins [optional]

postcss plugins config, see also postcss

postcssModulesOpts [optional]

postcss-modules plugins config, see also postcss-modules