[Answered ]-How to use bootstrap 5 with webpack loader?

1๐Ÿ‘

โœ…

I found what was my problem, I am sorry, but I still new with webpack.

I just install these packages:

  1. npm install sass-loader sass webpack --save-dev
  2. npm install --save-dev postcss-loader postcss

Then I just edited my webpack.config.js file to be like this:

const path = require("path");
const webpack = require("webpack");

module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.resolve(__dirname, "./static/frontend"),
        filename: "[name].js",
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader",
                },
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            }
        ],
    },
    optimization: {
        minimize: true,
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.env": {
                // This has effect on the react lib size
                NODE_ENV: JSON.stringify("production"),
            },
        }),
    ],
};

0๐Ÿ‘

I had a same error because of the wrong webpack configuration:

 {
    test: /\.css$/,
    exclude: /node_modules/,
    use: ['style-loader', 'css-loader']
  },

Iโ€™ve removed exclude field from the object.

๐Ÿ‘คmatrixb0ss

Leave a comment