Generate a production build for angular without including any dependencies in the bundle

138 Views Asked by At

I am creating a new angular application and want to be able to load all project dependencies such as angular libraries, rxjs, moment-js, etc externally from a common location (CDN) in the production build.

Is there a way to configure angular project in so that the dependencies / dev-dependencies mentioned in package.json are not bundled within the production build generated using "ng build --configuration production", there-by resulting in a smaller bundle size?

I generated angular build by changing the dependencies to dev-dependencies, but that had not been fruitful. I did not find any related options in the angular command-line documentation. Multiple searches on the Internet including Stack Overflow for the same did not land me on related topics.

1

There are 1 best solutions below

6
On

You can modify index.html to have them added in the head section.

<head>
  <script src="..." async defer></script>
</head>