zaricm
zaricm

Reputation: 3

Problem with loading CSS files in Webpack

This is now the second day I'm trying to figure out what I've might done wrong. So far, I've followed different tutorials, reading through Webpack documentation, tried to reinstall style-loader and css-loader and even started a setup on a different machine. No luck!

Here is the error appearing every time I start webpack bundle:

ERROR in ./src/style.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 {
|   background: green;
| }
 @ ./src/index.js 2:0-21

I'm thinking it might be something within my configuration, when I delete "module", I'm getting the same message:

const path = require("path");

module.export = {
    mode: "development",
    entry: "./src/index.js",
    output: {
        filename: "main.js",
        path: path.resolve(__dirname, "dist"),
    },
    module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
};

I've also installed all dependancies:

{
  "name": "Timer",
  "version": "1.0.0",
  "private": true,
  "description": "",
  "scripts": {
    "start": "webpack --config=webpack.config.js --mode=development"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "css-loader": "^4.2.1",
    "style-loader": "^1.2.1",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.12"
  },
  "dependencies": {
    "lodash": "^4.17.19"
  }
}

I'm new at this, so I don't know where to go from here...

Upvotes: 0

Views: 791

Answers (1)

Raz Ronen
Raz Ronen

Reputation: 2628

Like you mentioned in your comment:

Change module.export to module.exports.

Upvotes: 1

Related Questions