Search code examples
reactjsfirebase-hosting

Firebase hosting: Why firebase hosted my all the source code into there hosting? How can I restrict only to "build" folder?


I have build a react app and I used firebase hosting to deploy my app. It's working fine but firebase has hosted all the source code. I only need to upload build folder. How can I remove other files from the hosting?

firebase.json

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

enter image description here

Is there any thing to do?

But somehow I have uploaded build folder only for another app But I cannot remember/find how I did it, I see no different between firebase.json

enter image description here

firebase,json

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Solution

  • We have map files in build/static folder. Those files will re-generate the source files. So we can re-deploy the website after deleting .map files or change the firebase.json file.

    {
      "hosting": {
        "public": "build",
        "ignore": ["firebase.json", "**/.*", "**/node_modules/**", "**/**/*.map"],
        "rewrites": [
          {
            "source": "**",
            "destination": "/index.html"
          }
        ]
      }
    }