I am working with a legacy package in a monorepo and am including in the optimizeDeps array - is it possible to tell Vite to treat all .scss files it sees as CSS Modules files?
Originally asked in the vite discord: https://discord.com/channels/804011606160703521/1217522070343254016
The problem is that this legacy package has all its css modules files as plain .scss files instead of .module.scss which vite expects, and so I see this error:
The requested module '/@fs/Users/jakxz/go/src/.../components/fields/EditableField/EditableField.scss' does not provide an export named 'default''
EditableField.js is a compiled ESM react component that attempts to do
import styles from './EditableField.scss';
In your vite.config.js
export default { css: { preprocessorOptions: { scss: { modules: true } } } }This will ensure that Vite interprets all .scss files as CSS Modules