4

I'm setting up to deploy my Angular App to Firebase Hosting. But it just makes a default firebase index hosting, nothing change.

I had use firebase init and my dist dir public, ng build --prod to make app dist dir after that use firebase deploy.

ng build --prod make only a dist folder with all file. It does not contain any subfolder.

Firebase said that: I must add Firebase SDK, but I don't know where to add.

kaonashichan:toh noface$ firebase init

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /Users/noface

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory

? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Conf
igure and deploy Firebase Hosting sites

=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add, 
but for now we'll just set up a default project.

i  .firebaserc already has a default project, skipping

=== Hosting Setup

Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.

? What do you want to use as your public directory? dist
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? File dist/index.html already exists. Overwrite? No
i  Skipping write of dist/index.html

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!
kaonashichan:toh noface$ ng build --prod

Date: 2019-05-13T04:13:50.154Z
Hash: bbc9e5b91e532fbd9570
Time: 31202ms
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.c10271b9fdcd6058774f.js (main) 376 kB [initial] [rendered]
chunk {2} polyfills.f03d03a35f15175f61b1.js (polyfills) 66.4 kB [initial] [rendered]
chunk {3} styles.167b12e8ea2d1f694d59.css (styles) 765 bytes [initial] [rendered]
kaonashichan:toh noface$ firebase deploy
kaonashichan:toh noface$ firebase deploy

=== Deploying to 'autochessmo'...

i  deploying hosting
i  hosting[autochessmo]: beginning deploy...
i  hosting[autochessmo]: found 2 files in dist
✔  hosting[autochessmo]: file upload complete
i  hosting[autochessmo]: finalizing version...
✔  hosting[autochessmo]: version finalized
i  hosting[autochessmo]: releasing new version...
✔  hosting[autochessmo]: release complete

✔  Deploy complete!
Diện Vô
  • 71
  • 6
  • 1
    What are the contents of the dist folder after running the ng build command? Newer versions of @angular/cli put the application into a sub folder of dist. If that’s the case then you need to update the firebase deploy configuration to target the sub folder within dist. – Alexander Staroselsky May 13 '19 at 04:49
  • https://imgur.com/sEYGm8B This is my dist dir after building. and I used ```npm install -g @angular/cli``` command to install angular cli so I think it's newest version. – Diện Vô May 13 '19 at 04:58
  • Possible duplicate of [Angular 6.0 firebase hosting deploy not working](https://stackoverflow.com/questions/50360477/angular-6-0-firebase-hosting-deploy-not-working) – joka00 May 13 '19 at 06:04
  • Don't know why my ```ng build --prod``` is not made the-project-name subfolder, just dist as root with all file. – Diện Vô May 13 '19 at 06:44

2 Answers2

3

I had solved my problem. Don't know why firebase makes firebase.json file at user/name folder instead of my project folder. I just delete it and everything goes right!

Diện Vô
  • 71
  • 6
  • Thank you for your answer. I got the same problem. It happend because I have allready configured firebase before for emulating database, that's why firebase.json was at user/name directory, and deploy all files from there, instead of project directory. I deleted firebase.json, configured it once again and deployed successfully. – Юрий Яхница Jan 15 '22 at 17:58
0

it create a folder in user with your folder name. Which include just index and 404.html file.

So, after initialization (firebase init) find the folder in user folder and replace all file and then deploy

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 16 '22 at 07:51