After I setup SSR for my Angular 18 project, it properly worked. The issue lies on prerender option in project.json. When I change it to false, the project builds without any problem. But when it's true, the build gets stuck in chunk step. Adding --verbose doesn't show anything.
{
"build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/web-app",
"index": "./src/index.html",
"browser": "./src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "assets",
"output": "/assets"
}
],
"styles": ["./src/styles.scss"],
"scripts": [],
"server": "./src/main.server.ts",
"prerender": true, // this is the problem
"ssr": {
"entry": "./server.ts"
}
},
}
I just set prerender to true and false and found out that the problem is when prerender is set to true.
isPlatformBrowserto ensure that code only executes in the browser.