How to reduce moment with timezone package file using webpack

Viewed 15

I am importing two packages:

"moment": "^2.29.3",
"moment-timezone": "^0.5.34",

and in my js files:

import moment from "moment-timezone";

but when building the package, the size comes to 1.5MB.

Part of my webpack config:

optimization: {
        runtimeChunk: "single",
        splitChunks: {
            cacheGroups: {
                vendor: {
                    test: /[\\\/]node_modules[\\\/]/,
                    name: "moment",
                    chunks: "all",
                },
            },
        },
        minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
    },

I tried this method but the package size is still huge, just decreased by few kb.

Anyone familiar with how to reduce the moment package when using moment timezone?

0 Answers
Related