Use CSS Modules in React components with Typescript built by webpack

前端 未结 5 999
佛祖请我去吃肉
佛祖请我去吃肉 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:36

    import has special meaning to TypeScript. It means that TypeScript will attempt to load and understand the thing being imported. The right way is to define require like you mentioned but then var instead of import:

    var styles = require('../../../css/tree.css')`
    

提交回复
热议问题