I'm trying to build a project and I just moved my code from VSCode to Codesandbox. I must mention that the code was working fine in VSC but for some reason it's not working in Codesandbox - the CSS modules can't be found. I am thinking I am maybe missing something in my setup since I looked at other examples and the code seems identical (the imports). The error in getting for all the files is:
Cannot find module './Example.module.css' or its corresponding type declarations.
The complete code is here:
https://codesandbox.io/s/burger-builder-project-173uw?file=/src/Components/Layout/Layout.tsx
Does anyone have any idea what could be wrong? Thank you.
To get rid of the error you need to create a Typescript Declaration file for *.css
on the root folder and include it on the tsconfig.json
. Take a look on the changes below:
module.css.d.ts
declare module "*.module.css";
tsconfig.json
{
"include": [
"./src/*",
"./module.css.d.ts"
],
"compilerOptions": {
"strict": true,
"esModuleInterop": true,
"lib": [
"dom",
"es2015"
],
"jsx": "react"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With