0

I'm migrating our AngularJS project from Gulp to Webpack. I'm following the docs to the letter but I keep getting this error:

ERROR in ./src/js/index.js
Module not found: Error: Can't resolve './style.css' in '/Users/username/Development/yd-front-end/src/js'
 @ ./src/js/index.js 1:0-21
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/js/index.js
ℹ 「wdm」: Failed to compile.
^C

This is the index.js file:

import './style.css';

const stuff = '2';
console.log(stuff);

I replaced the style.css path above with the absolute path that even includes the hard disk and the dev server didn't throw an error, so it must be a pathing problem?

I can see the [name].bundle.js exporting just fine btw.

const path = require("path");

module.exports = {
  mode: "development",
  entry: "./src/js/index.js",
  output: {
    filename: "[name].bundle.js",
    path: path.resolve(__dirname, "dist/js")
  },
  devtool: "inline-source-map",
  devServer: {
    contentBase: "./src"
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      }
    ]
  }
};
Edgar Quintero
  • 4,223
  • 2
  • 34
  • 37
  • Does that file live in `/Users/username/Development/yd-front-end/src/js` ? If so this should work fine. If not, make it the correct relative path to `js/`, like `../css/style.css'` – Andy Ray Apr 19 '18 at 00:49
  • It does in that path, if I use that path it works fine :S – Edgar Quintero Apr 19 '18 at 00:59

0 Answers0