Firebase deploy, ignore all files but public folder

Use the glob ** to ignore any file or folder in an arbitrary sub-directory.

You can then un-ignore your dist folder with !dist

So your firebase.json file would look like:

{
    "database": {
        "rules": "database.rules.json"
        },
        "hosting": {
            "public": "dist",
            "ignore": [
                "**",
                "!dist/**"
            ],
            "rewrites": [{
                "source": "**",
                "destination": "/index.html"
            }
        ]
    }
}

For newer versions of Firebase:

It appears that new versions of firebase don't allow for the above mentioned method, so instead just define the folders which should be ignored:

{
    "database": {
        "rules": "database.rules.json"
        },
        "hosting": {
            "public": "dist",
            "ignore": [
                "**/node_modules/**",
                "**/src/**",
                "**/public/**"
            ],
            "rewrites": [{
                "source": "**",
                "destination": "/index.html"
            }
        ]
    }
}

You can use the Firebase console to check how many files have been deployed:

  1. Open your Firebase project's Hosting page and take note of the number of files.Firebase Hosting dashboard
  2. Run the command $ tree dist/ (since in this case dist/ is the folder we are serving on Firebase hosting) and take note of the number of files in the build folder. tree for build folder

These should roughly be the same number of files.