Angular 6.0 firebase hosting deploy not working

前端 未结 9 1813
鱼传尺愫
鱼传尺愫 2020-11-29 06:21

I am looking for a tutorial on how to properly setup the firebase-tools hosting on my angular 6.0 projects, and what I found is always like this.



        
相关标签:
9条回答
  • 2020-11-29 06:54

    There's one more issue that can lead to this very same page. When we init the project by using the

    firebase init

    command and following the procedure, it by default overwrites the index.html file. So, if already built(to get the dist/_Project_Folder) the index.html file is overwritten. Built it again after

    firebase init 
    ng build --prod
    
    0 讨论(0)
  • 2020-11-29 06:56

    I found that the ng build --prod will create a dist and an another subfolder under this where the project location is.

    dist
    |--TheProject_Folder
    |  |--assets|index.html - This index html is not using.
    |--index.html - This is the html generated in the firebase init
    

    So what I did is to initialize again the firebase init and change the public directory from dist to dist/TheProject_Folder:

    - What do you want to use as your public directory? dist/TheProject_Folder
    - Configure as a single-page app (rewrite all urls to /index.html)? Yes
    - Overwrite? No
    
    0 讨论(0)
  • 2020-11-29 06:58

    @bajran may have elborated all steps in detail but if you are migrating from angular 5 to 6, the only step that matters is, changing "public": "dist", to "public": "dist/your_project_name", in firebase.json

    0 讨论(0)
  • 2020-11-29 07:04

    It worked when I cleared the cache with ctrl+shift+R hard reset on the web! Make sure the correct index.html file is being deployed on firebase.

    0 讨论(0)
  • 2020-11-29 07:06

    it worked me after i remove cache and refresh browser, thanks.

    0 讨论(0)
  • 2020-11-29 07:15

    The problem is that on the question

    File dist/apps/ditectrev/index.html already exists. Overwrite?

    If you'll type Y for Yes, then it'll create its own index.html file, generated by Firebase. Giving this N for No I was able to keep my original index.html, which was generated after using ng build --prod in dist/apps/ditectrev. Note: I'm using Nx workspace, but the same should apply for other Angular projects. In normal Angular project case it would be different path, which would be simply dist.

    0 讨论(0)
提交回复
热议问题