I use some .scss
files as part of a re-usable ES6 module (ESM). As part of the build process I am running yarn sass -I node_modules src:dist
to compile all of these files to .css
and they are output to the /dist
directory.
Now, since it is an ESM modules I have to specify the file extension when importing a file, like import my-styles.css
. As with my other imports, I want to specify the extension that the file is compiled to, not the one used in the /src
folder.
Unfortunately, unlike with my other imports, vitest chokes on the .css
import – saying the file doesn’t exist. Is there a way to get vitest to either resolve the .css
file imports as .scss
when not found, or else to otherwise mock the .css
imports?