I am trying to clean up my deployment process to Firebase, and need to ignore all files besides my /dist
aka public folder when deploying files to the hosting. I believe it can be done via ignore
setting in firebase.json
, but I am not sure how to achieve it besides manually specifying all files.
example .json
:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"ignore": [
// ignore all other files besides dist folder here
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
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"
}
]
}
}
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:
$ 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.
These should roughly be the same number of files.