Last active
October 12, 2023 13:58
-
-
Save niksseif/d86c4a3c05e2f3ca834a4c09152024ca to your computer and use it in GitHub Desktop.
How to deploy your React/Parcel project on firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a gist of what to do if you are deploying your Parcel/React project on firebase. | |
1. add these scripts to your package.json in the root of your project | |
Package.json: | |
"scripts": { | |
"clear-build-cache": "rm -rf .cache/ dist/", | |
"dev": "parcel src/index.html", | |
"build": "cross-env NODE_ENV=production parcel build ./src/index.html --public-url ./", | |
"format": "prettier --write \"src/**/*.{js,jsx}\"", | |
"lint": "eslint \"src/**/*.{js,jsx}\" --quiet", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
make sure your index.html path is correct in the build script | |
dev: npm run dev will run your project locally. | |
clear-build-cache: npm run clear-build-cache will clear your .cach and dist file before running your build | |
format: npm run format it will run prettier for all your files. | |
2. than remove dist and cache files or you can run npm run clear-build-cache like mine in the package.json | |
3. now run npm run build. which it will make a dist folder for your project | |
4. init your firebase and make sure that your firebase.json public is connected to dist folder | |
Firebase.json: | |
"hosting": { | |
"public": "dist/", | |
"ignore": [ | |
"firebase.json", | |
"**/.*", | |
"**/node_modules/**" | |
], | |
"rewrites": [ | |
{ | |
"source": "**", | |
"destination": "/index.html" | |
} | |
] | |
} | |
5. Now it is time to run firebase deploy and deploy your project. | |
Please let me know if this is helpful to anyone. | |
Thank you!!! You're a lifesaver π
Thanks Man ππ»
Thank you all for leaving comments on this! @swiftrookie I am glad it was useful to you. π
Life Saver !!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for this! π