1

I just learned webpack and i got problem when run npm run start-dev my css not loaded. how to fix it?

this code on webpack.config.js:

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

this code on index.js

import "./style/style.css";
import $ from 'jQuery'
import 'bootstrap';

console.log("berhasil tehubung");

1 Answer 1

1

You probably need the file-loader webpack plugin too, I used this config for it in one of my webpack config files:

{
  loader: "file-loader",
  options: {
    name: "[name].css",
    outputPath: "css/",
  },
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.