To deploy my Angular project I ran ng build --configuration production and then firebase deploy --only hosting. It says:
Thank you for trying our early preview of Angular support on Firebase Hosting.
During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.
Documentation: https://firebase.google.com/docs/hosting/frameworks/angular
File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md
We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X
Error: No i18n config on project.
I have Transloco 5.0.7 installed. Reading how to Configure internationalization (i18n) rewrites, it appears that Firebase Hosting is looking for this:
"i18n": {
"root": "/localized-files"
},
in firebase.json. It expects to see localized-files in the public directory:
public/localized-files/
My Angular app doesn't have this directory structure. I have:
src/app/assets/i18n/
I tried
"i18n": {
"root": "src/app/assets/i18n/"
},
"i18n": {
"root": "app/assets/i18n/"
},
"i18n": {
"root": "/assets/i18n/"
},
and
"i18n": {
"root": "assets/i18n/"
},
These all throw similar errors:
hosting: Couldn't find specified i18n root directory /assets/i18n in public directory .
Is there another config line in firebase.json that tells Firebase Hosting that Angular puts index.html in an app directory, not a public directory?
I figured it out.
The two doc pages I read were:
Configure Hosting behavior
Configure internationalization (i18n) rewrites
If you have Transloco installed and running you don't need to touch anything there. Find the folder with your Transloco files. My folder is in
Open
firebase.jsonand make two changes. First, put in the path to youri18nfolder:Next, remove the line
"source": ".",and replace it with the path to the folder that contains yourindex.htmlfile. Firebase calls this yourpublicdirectory.Watch out for a few things. First, don't use
source. This no longer works. You must usepublic.Second,
publicpoints to the directory that contains yourindex.htmlfile. An Angular app has twoindex.htmlfiles! In fact, Angular apps have two of every file:srcanddist.distis where your compiled, ready to deploy files are. Don't point yourpublicfolder tosrc.Third, I have no idea why Angular compiles my app into
dist/en-USinstead ofdist. I think this is a bug in Transloco.Here's my entire
firebase.jsonfile: