escapecharacter
escapecharacter

Reputation: 965

Webpack not recognizing css-loader

My app runs normally with yarn, but cannot load the css when I use a benchmarking library react-benchmark, which uses webpack. An minimal example of the entire project is here: https://github.com/dustinfreeman/bug-react-benchmark-css-import

Here is the loading error:

$ react-benchmark --debug src/index.tsx
✖ Compiling bundle
/Users/dustinfreeman/Documents/Code/bug-react-benchmark-css-import/src/index.css 1:5
Module parse failed: Unexpected token (1:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> body {
|   font: 14px 'Century Gothic', Futura, sans-serif;
|   margin: 20px;
 @ /Users/dustinfreeman/Documents/Code/bug-react-benchmark-css-import/src/index.tsx 3:0-21
 @ ./client.js

webpack.config.js

export const module = {
  rules: [
    {
      test: /\.(css|scss)$/,
      use: [
        'style-loader',
        {
          loader: 'css-loader',
          options: {
            importLoaders: 1,
            modules: {
              localIdentName: "[name]__[local]___[hash:base64:5]",
            },
          }
        }
      ],
      include: /\.module\.css$/
    },
    {
      test: /\.(css|scss)$/,
      use: [
        'style-loader',
        'css-loader'
      ],
      exclude: /\.module\.css$/
    },
  ],
};

Upvotes: 0

Views: 396

Answers (1)

Anon
Anon

Reputation: 1

Inline worked for me. Try: import "style-loader!css-loader!./index.css"

Upvotes: 0

Related Questions