Nx Angular Workspace: How to share the index.html between multiple apps?

Viewed 745

I currently have 3 apps in my nx workspace. All of these are Angular applications, so they all have an index.html file in the app-name/src folder. As these apps will all be deployed to the same domain by using different "url-subsets" they use to have the exact same index.html (meta tags, fav icon etc.)

It's obvious I don't want them to be redundant in each app, but rather have a shared index.html.

How could this be done?

2 Answers

This should work: You could try to change the path of the "index" property in the angular.json. So you have one index.html file in the root of your nx project and all apps have the index defined as "index.html" in the angular.json

@Eweren's answer works!

starting the path to the lib with ./ like so:

"index": "./libs/name-of-lib/index.html"

I prefer @Eweren's answer, but yet there's another way to accomplish it by setting up fileReplacements for the index file in each project.

Related