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'
]
}
]
}
};