Trying to add css modules using style-loader and css-loader. Having a hard time figuring this out. I'm also not sure whether it's ts-loader to blame or css-loader.
webpack.config.js
const path = require('path'); module.exports = env => { return { devtool: "inline-source-map", entry: "./src/index.tsx", output: { path: path.resolve(__dirname, "/public"), filename: "build/app.js" }, resolve: { extensions: [".ts", ".tsx", ".js", ".json"], }, module: { rules: [ { test: /\.tsx?$/, loader: "ts-loader", }, { test: /\.css$/, loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' } ] } } }
component
import styles from "./Main.css"; // TS2307: Cannot find module './Main.css'.
P.S. I tried using the extract-text-webpack-plugin
, but that only messed up everything even more making the errors overwhelming