提交 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
- [pnpm](https://github.com/pnpm/pnpm)
Set up firebase:
- install Firebase Tools: `npm i -g firebase-tools`
- 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>
- update the `.firebaserc` default project ID to the newly created project
Install project:
Each of the other commands pre-installs all dependencies
```bash
npm install
```
Run Next.js development:
......@@ -35,7 +38,7 @@ Run Firebase locally for testing:
npm run serve
```
Deploy it to the cloud with Firebase
Deploy it to the cloud with Firebase:
```bash
npm run deploy
......@@ -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).
## 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.
* `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.
......
{
"name": "app",
"version": "1.0.0",
"description": "Next.js React SSR App",
"dependencies": {
"next": "beta",
"react": "^15.6.1",
"react-dom": "^15.6.1"
"next": "4.0.0-beta.2",
"react": "16.0.0",
"react-dom": "16.0.0"
},
"scripts": {
"dev": "next",
......
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"version": "1.0.0",
"dependencies": {
"firebase-admin": "^5.0.1",
"firebase-functions": "^0.6.0",
"next": "beta",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"private": true
"firebase-admin": "5.3.0",
"firebase-functions": "0.6.3",
"next": "4.0.0-beta.2",
"react": "16.0.0",
"react-dom": "16.0.0"
}
}
{
"name": "with-firebase-hosting",
"version": "1.0.0",
"description": "Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects.",
"version": "2.0.0",
"description":
"Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects.",
"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",
"serve": "firebase serve",
"predeploy": "npm run build-all",
......@@ -11,10 +15,5 @@
"build-all": "npm run build-next && npm run build-firebase",
"build-next": "cd \"app\" && npm i && npm run build",
"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.
先完成此消息的编辑!
想要评论请 注册