0

While using react-day-picker, i get the following error:

You may need an appropriate loader to handle this file type.  
| /* DayPicker styles */ |  
 | .DayPicker { | display: -webkit-box; |  

display: -ms-flexbox; @  
 ./src/components/portfolio/RecordInvestorDetail.react.js 47:0-41  

Module parse failed: /home/yash/Documents/CRONJ/waccal/node_modules/react-day-picker/lib/style.css Line 3: Unexpected token .

_

enter image description here

Geraint
  • 3,314
  • 3
  • 26
  • 41
Yash Sharma
  • 811
  • 1
  • 9
  • 27

3 Answers3

2

You must install and enable style-loader and css-loader for Webpack:

npm install style-loader css-loader --save-dev

Then add those loaders in webpack.config.js:

{
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" }
        ]
      }
    ]
  }
}
Przemysław Zalewski
  • 3,836
  • 1
  • 23
  • 23
1

I resolved the error by adding

loaders : [
'style',
]

I already had

loaders : [
          'style-loader',
          'css-loader',
          'autoprefixer?browsers=last 2 version',
          'sass-loader?includePaths[]=' + paths.src('styles')
        ]

Now the loaders are

loaders : [
          'style',
          'style-loader',
          'css-loader',
          'autoprefixer?browsers=last 2 version',
          'sass-loader?includePaths[]=' + paths.src('styles')
        ]
Yash Sharma
  • 811
  • 1
  • 9
  • 27
0

I had this configuration before:

{
    test: /\.css$/,
    exclude: /node_modules/,
    use: ["style-loader", "css-loader"],
}

And got the issue fixed by removing the line: exclude: /node_modules/

I wasnt allowing webpack to compile the files from react-day-picker by having this.

the correct:

{
    test: /\.css$/,
    use: ["style-loader", "css-loader"],
}