How to import CSS modules in Typescript with Webpack?
Generate (or auto-generate)
.d.ts
files for CSS? And use classic Typescriptimport
statement? With./styles.css.d.ts
:import * as styles from './styles.css'
Import using
require
Webpack function?let styles = require("./styles.css");
But for the last approach I must define the require
function.
What is the best approach or best option and one that can also handle IntelliSense for the CSS file definitions and classes?
This is just what I used to do and still have that code in a few of my projects out there.
Now : I wrote typestyle : http://typestyle.github.io/#/ but you don't have to use it. Just stick with
const styles = require('./styles.css')
if it makes you happy. FWIW you can also use raw css with typestyle if you want http://typestyle.github.io/#/raw