angular 7 How to reduce production build size

363 views Asked by At

How to reduce production build size.

production build : ng build --prod

angular.json config file:

enter image description here

enter image description here

enter image description here

main.js(4.3mB) has pdf.js(303kB), pdf_viewer.js(100kB) apart from these a seperate pdf.worker.js(739kB) is also present.

cpexcel.js and xlsx.js are taking more space.

i never used jszip present in xlsx

Iam using ng2-pdf-viewer to work with pdf files.


Dev build: ng build

enter image description here

here main.js(1.2mb) does not contain pdf.js(303kB), pdf_viewer.js(100kB). These are included in vendor.js.

But has pdfworker.js of size 1.51mB

Thanks

1

There are 1 answers

0
tsu On BEST ANSWER

I've had similar issu, for my solution: You can intall custom-webpack to your devDependencies

Read their doc to see how to use this package, there is my confituration extrat-webpack.config.js of to remove cpexcel and jszip

module.exports = {
    resolve: {
        alias: { 
            "./dist/cpexcel.js": "",
            "./jszip.js": ""
        }
    },
};

By the way, I'm using angular 9 and "@angular-builders/custom-webpack": "^10.0.0",