2

In Angular 13 when I build my application, I recieve the following warning:

Option "deployUrl" is deprecated: Use "baseHref" option, "APP_BASE_HREF" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url.

I have read the documentation page but I am struggling to wrap my head around it.

This occurs because in my angular.json I have multiple builds, but this only applies to the production configuration:

...
    deployURL: "https://cdn.lol.com/prod/app"
...

What would I need to do to achieve the same outcome as deployURL?

I considered creating an environment.production.ts file with a baseHref property and then I could use a provider in my app module. (See APP_BASE_HREF Docs) but assuming I do that, I don't really understand where I would use the Token correctly. I also don't really understand what my new relationship would be with assets.

As far as I understand, deployURL was specifically for routes, whereas baseHref effects both routes and assets (or can?). This seems to open a can of worms.

I would appreciate any insight!

Thanks.

user1059939
  • 1,613
  • 2
  • 20
  • 37
  • To get the same outcome of deployUrl you might use a custom-webpack builder for your app and configure your webpack.config.js publicPath. Which will result the same as deployUrl. – Mehyar Sawas Dec 14 '21 at 19:58
  • @MehyarSawas Thanks for the suggestion, although I am familar with Webpack, I don't fancy digging that deep or maintaining it. The app is from version 4 and has passed all versions through to 13, so if I had to consider maintaining a custom webpack config through all of this time, i'd be probably grey haired! :)! – user1059939 Dec 14 '21 at 21:00
  • @user1059939 have you been able to fix this issue? – Tristan Van Poucke Nov 26 '22 at 14:55
  • @TristanVanPoucke Nope We actually decided to host assets externally, not for this particular reason but it made the original question obsolete. Good luck. – user1059939 Dec 05 '22 at 17:11
  • 1
    Okay tnx, I'll guess I will log an issue with angular, cause none of the alternatives proposed offer a solution for this case... – Tristan Van Poucke Dec 06 '22 at 14:06

1 Answers1

0

In app.module.ts, you can use it like below given SS to update the deploy url.

enter image description here