You might want to consider splitting your chunks. Like you can have separate chunk for your own code and node_modules.

You might want to minify your code in production mode to reduce the bundle size. Here's what you can do with your webpack config file:

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

optimization: splitChunks: {
    cacheGroups: {
      vendor: {
        chunks: "initial",
        test: path.resolve(process.cwd(), "node_modules"),
        name: "vendor",
        enforce: true
  minimizer: [
    new UglifyJSPlugin({
      uglifyOptions: {
        sourceMap: true,
        compress: {
          drop_console: true,
          conditionals: true,
          unused: true,
          comparisons: true,
          dead_code: true,
          if_return: true,
          join_vars: true,
          warnings: false
        output: {
          comments: false

This will create separate bundle for your node_module which you can include in your main file.

Related Query

More Query from same tag