反应日选择器的加载器问题

loader issue with react-day-picker

在使用 react-day-picker 时,出现以下错误:

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 .

_

您必须为 Webpack 安装并启用 style-loader and css-loader

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

然后在 webpack.config.js 中添加那些加载程序:

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

我通过添加

解决了错误
loaders : [
'style',
]

我已经有

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

现在装载机

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

我之前有过这样的配置:

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

并通过删除以下行解决了问题: 排除:/node_modules/

我不允许 webpack 通过这个从 react-day-picker 编译文件。

正确的:

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