user11081980
user11081980

Reputation: 3289

Angular 2 and WebPack: how to reduce the size of the bundle?

I tried a few Angular 2 seed projects that use WebPack. When I build the bundle to release it to Prod, I end up with a file of about 3MB.

How could I reduce the size of this file?

One such project is: https://github.com/mgechev/angular-seed

Upvotes: 2

Views: 1435

Answers (3)

senthil
senthil

Reputation: 229

There are some important things how to reduce your bundle size:

  1. Try to use lazyLoading. This will be great to reduce the main bundle size, and it will split as a chunk files.
    Refer to this document : https://angular.io/guide/router

  2. remove the unwanted Packages.
    Example:
    if you want to use the boostrap modal module, you can import it like this import {modalModule} from ngx-boostrap/modal

Upvotes: 0

user3682091
user3682091

Reputation: 755

I don't think the project you provided use webpack.

If you are just looking for a seed project, you can checkout angular-cli. ng build --target=production do a pretty good production build.

If you are using webpack now, one thing you can check is the devtool in your webpack config, make sure it is not eval. Use source-map may help.

Upvotes: 2

kemsky
kemsky

Reputation: 15279

Minimum size with Webpack is around 800kb for empty application, i suspect you are doing something wrong. Source maps are optional.

Upvotes: 1

Related Questions