反应模块化CSS

时间:2018-06-12 13:45:57

标签: reactjs webpack webpack-style-loader react-css-modules

我已经为css正确设置了webpack,但仍然出错。可能的原因是什么?

ERROR in ./src/main/main.css 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .whiteBackground {
|    background: white;
| }
 @ ./src/main/main.js 15:12-33
 @ ./src/index.js

这是我的webpack.config.js

const HtmlWebPackPlugin = require("html-webpack-plugin");

const htmlWebpackPlugin = new HtmlWebPackPlugin({
  template: "./src/index.html",
  filename: "./index.html"
});

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.css$/,
        use: [
          {
            loader: "style-loader"
          },
          {
            loader: "css-loader",
            options: {
              modules: true,
              importLoaders: 1,
              localIdentName: "[name]_[local]_[hash:base64]",
              sourceMap: true,
              minimize: true
            }
          }
        ]
      },
      {
        test: /\.(woff|woff2|ttf|svg|eot)$/,
        use: [
            {
                loader: 'file-loader',
                options: {}
            }
         ]
      }
    ]
  },
  plugins: [htmlWebpackPlugin]
};

/ ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** / / ****** /

0 个答案:

没有答案