You can do this on the server side. My experience is with Asp.Net and Asp.Net Core but this can be done in Node also. You can serve the index.html page from either an endpoint or a controller and just add authentication to that endpoint. Nobody can load the index.html page without first authenticating.
For what it is worth though I have never found this to be necessary if all your apis are protected. The user would have to have quite a bit of knowledge to tweak the javascript since it is mostly minified and even if they did they can't call any api without authenticating. I have gone away from trying to protect the entire app and instead use lazy loading. The app module only contains the authentication code and one route that loads the shell module after authentication. This route is protected by a guard that triggers the authentication. If you are not using server side rendering then an Angular app is just a bunch of static files that really should be served from a CDN and not though a server endpoint.