I am currently working on an Angular 17 project and recently generated a new empty project using Angular CLI with PWA (Progressive Web App) and SSR (Server-Side Rendering) features. However, I noticed that the size of the initial files is surprisingly large, even for an empty project.
The project starts with a standalone component, and I expected the size of the initial bundle to be relatively small. However, the initial bundle currently weighs around 214 KB.
I have verified that optimization is properly configured in the angular.json file and that I am using the ng build --configuration=production to build the project.
Is it normal to have such a large bundle size for an empty project with PWA and SSR? Are there any additional optimizations I could apply to reduce the size of the initial files?
Thank you in advance for your assistance and advice.
The app.conf.ts
import {ApplicationConfig, isDevMode} from '@angular/core';
import {provideRouter} from '@angular/router';
import {routes} from './app.routes';
import {provideClientHydration} from '@angular/platform-browser';
import {provideServiceWorker} from '@angular/service-worker';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideClientHydration(),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})]
};
The main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
adding in prod conf :
"optimization": true
Around 250kB looks to be normal size for the bare Angular project that imports the Router.
The router is known to have a low tree-shakability.
There isn't much to optimize here.