Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 9, 2021 03:07 pm GMT

Speeding up the development builds after upgrading to Angular v12

After you've upgraded to Angular v12 from a previous version of Angular, you may notice your ng serve times have increased, along with missing sourcemaps, and longer rebuild times during development. This post helps you set a default configuration to development to get your application serving the same as previously.

In Angular version 12, running ng build now defaults to production mode. This is a welcomed change, as there is less chance of accidentally deploying a development build to production, which is a lot slower and bigger, giving the perception that Angular is slow. This also aligns with other web frameworks that build for production out of the box.

The way Angular serves the application, it essentially does a build with watch mode. As mentioned before, doing a build is now done by default with production optimizations enabled. This adds more time to the build process.

There is a migration to add a "development" build configuration.

To run this migration, run:

ng update @angular/cli --migrate-only production-by-default

One caveat is that it only supports migrating first-party Angular builders for development mode, including:

  • @angular-devkit/build-angular:dev-server
  • @angular-devkit/build-angular:protractor

To fix this manually, you add the development options as defaults, and a defaultConfiguration set to an empty string so it doesn't default to production.

Now, when running ng serve you will get a development build, which is faster for local development.

If you liked this, click the so other people will see it. Follow me on Twitter for more tips on Angular, Nx, and NgRx!

See Also


Original Link: https://dev.to/brandontroberts/speeding-up-the-development-serve-after-upgrading-to-angular-v12-5db5

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To