I'm following the advice here on preventing the typescript error 'Cannot find module path/to/style.css' on my CSS Module imports (i.e. import styles from 'path/to/style.css') by creating a Global.d.ts file.
But now when I click on the styles variable, it opens up the global type file.
The same thing happens for 'svg' files.
jsconfig.json
{
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"jsx": "react",
"checkJs": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"path/*": ["./src/my/path/*"],
}
}
}
webpack.config.js
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 1,
localIdentName: "[name]",
}
}
]
},
I am hoping for a solution that a) removes the erroneous error and b) works with any file ending (e.g. .svg as well.)