Reputation: 785
I am trying to host my Angular(5) project on Firebase and I am able to deploy my application but when I do this is what the host shows at my project URL:
It seems like I am able to deploy a hosting service using Firebase but it is not actually using my Angular project, instead just a default Firebase hosting screen. My firebase.json file is currently set up like below:
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Additionally, I ran ng build --prod --aot=false beforehand to build a production folder in my angular project under 'dist'. Why is my project not showing up at the URL? The dist folder structure is as such:
Also, here is my configuration for setting up Firebase init:
Upvotes: 4
Views: 1937
Reputation: 38174
My actions to deploy Angular 7.2.15
to Firebase:
Run firebase init
Then:
ng build --prod
After that the project has the following structure:
-.firebase
-dist
- myapp
-node_modules
-myapp
- dist
-myapp
-public
-.firebaserc
-.gitignore
-.firebase.jsom
-package-lock.json
Then you should copy ALL FILES from myapp/dist/myapp
into dist/myapp
.
Then run firebase deploy
Upvotes: 0
Reputation: 839
step 1 : ng build --prod after step 1 in src/app/ --> dist folder with deploy/hosting content will be created/updated
step 2: firebase deploy -p dist/< Enter Your Project Name here > ex: (test is project name) : firebase deploy -p dist/test
in 2nd step deploy of files in dist folder to firebase hosting (as u can see this files in firebase console)
Upvotes: 0
Reputation: 2800
In Angular 6 you need to add the project name at the public property.
{
"hosting": {
"public": "dist/projectName",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
You need the dist
because that is the folder where the production files can be found when you execute the ng build --prod
command
Upvotes: 0
Reputation: 929
Can you provide the full tree directory of your app ?
I have a Angular application hosted in Firebase Hosting and my firebase.json is similar as yours but not this line :
{
"hosting": {
"public": "public/dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Could be a solution ... or not. It depends on your directory tree. Please share your directory tree to compare.
Upvotes: 0