I've stumbled upon this question today also and found that TS now can import css directly with webpack
and awesome-typescript-loader
exactly like this:
import "./home.css";
But if you like me want to use CSS modules, than you will have to add some more steps:
npm install --save-dev typings-for-css-modules-loader
- Change your
css-loader
to typings-for-css-modules-loader
- Change your webpack config to smth like this:
```
module: {
rules: [
{ test: /\.tsx?$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' },
{ test: /\.css$/, use: isDevBuild ? ['style-loader', "typings-for-css-modules-loader?namedExport&modules"] : ExtractTextPlugin.extract({ use: 'typings-for-css-modules-loader?minimize&namedExport&modules' }) },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=1000' }
]
}
This will generate typings for css files and you will be able to use them like
import * as style from './home.css';
Here is the article I used for my config: https://medium.com/@sapegin/css-modules-with-typescript-and-webpack-6b221ebe5f10