Use CSS Modules in React components with Typescript built by webpack

前端 未结 5 1007
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 18:57

I want to use the css-loader with the \'modules\' option of webpack in a React application written in Typescript. This example was my starting point (they are using Babel, w

5条回答
  •  被撕碎了的回忆
    2020-12-15 19:24

    I had similar problem. For me, works import:

    import '../../../css/tree.css';
    

    Webpack change this like any other normal imports. It change it to

    __webpack_require__(id)
    

    One drawback is that you lost control on style variable.

提交回复
热议问题