Local serving does not work following upgrade to Angular 13
π Bug report
- [ ] new
- [ ] build
- [x ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Description
I have two Angular applications in my project, a main app, then a much smaller app for testing our internal UI component library. It's also an NX monorepo.
I've just upgraded to Angular 13 (using nx migrate and the prod builds and main application serve are all working as expected.
Unfortunately, the small UI component app is not working with serve. Previously our script command in package.json used to use the --base-href flag, but now in Angular 13 this has been removed and gives message:
'baseHref' is not found in schema
So I have removed the --base-href flag from the command in package.json.
I've tried adding the exact same config to the angular.json file in the root of the project, like this:
"build": {
"options": {
"baseHref": "/component-guide",
// rest of config
}
}
But this has not worked. The actual serve command completes successfully, but when I try to hit my app in the browser at URL localhost/component-guide it just goes crazy and reloads like every 10 milliseconds (it is just reloading like crazy, the favicon is actually flashing, never seen anything like it)
I also tried adding the same baseHref config to the project.json file in the apps/component-guide folder (and having it in both angular.json and project,json individually and at the same time).
π¬ Minimal Reproduction
I'm sorry, but there isn't a minimal reproduction - my project is enormous and contains not just one but two separate applications. I can provide any additional information, or examples from my config files, but I cannot share the project as it is a commercial product.
π₯ Exception or Error
Application reloads hundreds of times per second
π Your Environment
Angular CLI: 13.1.3
Node: 16.13.2
Package Manager: npm 8.1.2
OS: win32 x64
Angular: 13.2.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1301.3
@angular-devkit/build-angular 13.1.3
@angular-devkit/core 13.1.3
@angular-devkit/schematics 13.1.3
@angular/cli 13.1.3
@schematics/angular 13.1.3
rxjs 6.5.5
typescript 4.5.4
Anything else relevant? Windows 10 Chrome 98
Hi, i have the same issue but for me the problem append with version 13.2.0, before, all work fine.
Yes, this is version I am using also @Shinzah, although I just noticed that angular CLI version is different from angular core version
Base href issue This is expected and working as intended as the base-href option was deprecated several versions ago and removed in v13 from the dev-server builder.
Multiple reloads Without a reproduction we will be unable to investigate this issue. However, before anything I suggest you to update to the latest version of the Angular CLI.
A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here. You can read here why this is needed.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
Thanks @alan-agius4, I've just tested with latest CLI and the behaviour is the same. This isn't two separate issues - the multiple reloads issue is directly related to removal of baseHref. It doesn't just reload once or twice - the app constantly reloads in the browser (to the extent where the favicon is literally flashing because it is reloading so frequently)
I don't think it's related to the folder structure tbh, as the folder structure has not changed at all, literally the only thing that has changed is that I've upgraded from Angular 12 to Angular 13. This worked as expected in Angular 12.
I appreciate that the --base-href option has been removed and can no longer be passed on the command-line, but why does this config not work in the builder config in angular.json? Has it been removed from here also? If so, where should I provide this configuration?
I don't think I can provide a minimal reproduction - the reproduction would not be minimal because of the complexity of the project - the project is enormous, has two distinct applications (one of which is working perfectly), is using NX structure, and docker.
Edit:
I also tried using serve-path=component-guide in command in package.json but this did not work either
I Just need the direct equivalent to supplying --base-href on the command line, because everything was working as expected when I was able to do that. I tried moving the config to angular.json, but it seems that this is not a direct equivalent
The baseHref option needs to be set in the browser builder like the below example:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"baseHref": "/foo",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
...
Unfortunately, without a minimal reproduction there isn't much we can do to investigate this issue.
Ok, that's the place where I tried to add it, but it made no difference sadly. I understand, I don't think it will be possible to create a minimal repro so I will go ahead and close the issue, thanks.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.