I have a Vite/React/Typescript app configured with sass and I would like to:
- Import the styles as named imports:
import { styles } from "my-component.styles.scss";
- Configure Vite (or sass) to recognize all
*.styles.scss
files as css modules as it happens for*.modules.scss
Here is my Vite config file
/// <reference types="vitest" />
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { defineConfig } from "vite";
// /config/
export default defineConfig({
plugins: [react()],
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler"
}
},
modules: {
localsConvention: "camelCase"
}
}
});