Make all style files supported css module, not just xxx.module.xxx
npm i vite-plugin-css-modules | yarn add vite-plugin-css-modules
import vitePluginCssModules from "vite-plugin-css-modules";
export default {
plugins: [vitePluginCssModules()],
};
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
}
}
]
}),
postcss plugins config, see also postcss
postcss-modules plugins config, see also postcss-modules