提交 594b214a 编写于 作者: J James Hegedus 提交者: Tim Neutkens

Update with-firebase-hosting. (#3032)

Simplify scripts.
上级 285b27b3
...@@ -15,13 +15,16 @@ It is recommended to use a package manager that uses a lockfile and caching for ...@@ -15,13 +15,16 @@ It is recommended to use a package manager that uses a lockfile and caching for
- [pnpm](https://github.com/pnpm/pnpm) - [pnpm](https://github.com/pnpm/pnpm)
Set up firebase: Set up firebase:
- install Firebase Tools: `npm i -g firebase-tools`
- create a project through the [firebase web console](https://console.firebase.google.com/) - create a project through the [firebase web console](https://console.firebase.google.com/)
- grab the projects ID from the web consoles URL: https://console.firebase.google.com/project/<projectId> - grab the projects ID from the web consoles URL: https://console.firebase.google.com/project/<projectId>
- update the `.firebaserc` default project ID to the newly created project - update the `.firebaserc` default project ID to the newly created project
Install project: Install project:
Each of the other commands pre-installs all dependencies ```bash
npm install
```
Run Next.js development: Run Next.js development:
...@@ -35,7 +38,7 @@ Run Firebase locally for testing: ...@@ -35,7 +38,7 @@ Run Firebase locally for testing:
npm run serve npm run serve
``` ```
Deploy it to the cloud with Firebase Deploy it to the cloud with Firebase:
```bash ```bash
npm run deploy npm run deploy
...@@ -46,7 +49,7 @@ The goal is to host the Next.js app on Firebase Cloud Functions with Firebase Ho ...@@ -46,7 +49,7 @@ The goal is to host the Next.js app on Firebase Cloud Functions with Firebase Ho
This is based off of the work at https://github.com/geovanisouza92/serverless-firebase & https://github.com/jthegedus/firebase-functions-next-example as described [here](https://medium.com/@jthegedus/next-js-on-cloud-functions-for-firebase-with-firebase-hosting-7911465298f2). This is based off of the work at https://github.com/geovanisouza92/serverless-firebase & https://github.com/jthegedus/firebase-functions-next-example as described [here](https://medium.com/@jthegedus/next-js-on-cloud-functions-for-firebase-with-firebase-hosting-7911465298f2).
## Important & Caveats ## Important / Caveats
* The empty `placeholder.html` file is so Firebase Hosting does not error on an empty `public/` folder and still hosts at the Firebase project URL. * The empty `placeholder.html` file is so Firebase Hosting does not error on an empty `public/` folder and still hosts at the Firebase project URL.
* `firebase.json` outlines the catchall rewrite rule for our Cloud Function. * `firebase.json` outlines the catchall rewrite rule for our Cloud Function.
* Testing on Firebase locally requires a complete build of the Next.js app. `npm run serve` handles everything required. * Testing on Firebase locally requires a complete build of the Next.js app. `npm run serve` handles everything required.
......
{ {
"name": "app", "name": "app",
"version": "1.0.0", "description": "Next.js React SSR App",
"dependencies": { "dependencies": {
"next": "beta", "next": "4.0.0-beta.2",
"react": "^15.6.1", "react": "16.0.0",
"react-dom": "^15.6.1" "react-dom": "16.0.0"
}, },
"scripts": { "scripts": {
"dev": "next", "dev": "next",
......
{ {
"name": "functions", "name": "functions",
"description": "Cloud Functions for Firebase", "description": "Cloud Functions for Firebase",
"version": "1.0.0",
"dependencies": { "dependencies": {
"firebase-admin": "^5.0.1", "firebase-admin": "5.3.0",
"firebase-functions": "^0.6.0", "firebase-functions": "0.6.3",
"next": "beta", "next": "4.0.0-beta.2",
"react": "^15.6.1", "react": "16.0.0",
"react-dom": "^15.6.1" "react-dom": "16.0.0"
}, }
"private": true
} }
{ {
"name": "with-firebase-hosting", "name": "with-firebase-hosting",
"version": "1.0.0", "version": "2.0.0",
"description": "Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects.", "description":
"Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects.",
"scripts": { "scripts": {
"next": "npm run build-firebase && cd \"app\" && npm i && npm run dev", "install-app": "cd \"app/\" && npm i",
"install-functions": "cd \"functions/\" && npm i",
"postinstall": "npm run install-app && npm run install-functions",
"next": "cd \"app\" && npm run dev",
"preserve": "npm run build-all", "preserve": "npm run build-all",
"serve": "firebase serve", "serve": "firebase serve",
"predeploy": "npm run build-all", "predeploy": "npm run build-all",
...@@ -11,10 +15,5 @@ ...@@ -11,10 +15,5 @@
"build-all": "npm run build-next && npm run build-firebase", "build-all": "npm run build-next && npm run build-firebase",
"build-next": "cd \"app\" && npm i && npm run build", "build-next": "cd \"app\" && npm i && npm run build",
"build-firebase": "cd \"functions\" && npm i" "build-firebase": "cd \"functions\" && npm i"
},
"dependencies": {
"next": "^3.0.1-beta.8",
"react": "^15.6.1",
"react-dom": "^15.6.1"
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册