How to import css file for into Component .jsx file

后端 未结 3 781

I am trying to use the react-day-pickers component like so but I can\'t figure out how to import the .css file and I keep getting the error:

Module parse fai         


        
3条回答
  •  借酒劲吻你
    2021-01-06 19:02

    How are you compiling this? If it's webpack, you'd probably need to bring in the style-loader and include something like this in the module.loaders array in your webpack config:

    {
      test: /\.css$/,
      loader: "style!css"
    }
    

    Update: With the webpack.config.js now provided, we can confirm it needed a change in the module.loaders array. OP was using a less loader and only checking for .less files, so the exact loader object should read:

    {
      test: /\.(less|css)$/,
      loader: 'style!css!less'
    }
    

    As suggested by @Q Liu. Leaving the original bit as if someone comes here with an error importing a .css file, it's likely what they need.

提交回复
热议问题