webpack main.js file size is 6.3 in “webpack –mode production”

I am using webpack to combine django & React js.
but main.js bundle file is too large (6.3 MB)
so the page to much time to load

webpack.config.js

const path = require("path");
const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

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",
        },
      },
      // Additional configuration to handle *.css files
      {
        test: /.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /.svg$/,
        use: ["@svgr/webpack"],
        use: [
          {
            loader: "svg-url-loader",
            options: {
              limit: 10000,
            },
          },
        ],
      },
      {
        test: /.(png|jpg)$/,
        type: "asset/resource",
      },
    ],
  },
  optimization: {
    minimize: true,
  },
  performance: {
    hints: false,
    maxEntrypointSize: 512000,
    maxAssetSize: 512000,
  },
  plugins: [
    new NodePolyfillPlugin(),
    new webpack.DefinePlugin({
      "process.env.NODE_ENV": JSON.stringify("production"),
    }),
  ],
};

babel.config.json

{
      "presets": [
        [
          "@babel/preset-env",
          {
            "targets": {
              "node": "10"
            }
          }
        ],
        "@babel/preset-react"
      ],
      "plugins": ["@babel/plugin-proposal-class-properties"]
    }
  

My pakage.json Installed is

  • “webpack”: “^5.75.0”,
  • “webpack-cli”: “^5.0.0”

I am unable to optimize with minimize = true
Its show error when minimize = true

ERROR in main.js main.js from Terser plugin