Unverified Commit 97d8e07f authored by Sakito Mukai's avatar Sakito Mukai Committed by GitHub

[Example] fix with-firebase-hosting (#16577)

parent 694ccc7c
...@@ -70,7 +70,6 @@ Then you can create components and pages in `.tsx` or `.ts` ...@@ -70,7 +70,6 @@ Then you can create components and pages in `.tsx` or `.ts`
- The empty `public/.gitignore` file is to ensure `public/` dir exists as it is required for Firebase Hosting. It is [configured](firebase.json:#L4) (by [default](https://firebase.google.com/docs/hosting/full-config#ignore)) that dotfiles (`public/.*`) are ignored from bein publicly served. - The empty `public/.gitignore` file is to ensure `public/` dir exists as it is required for Firebase Hosting. It is [configured](firebase.json:#L4) (by [default](https://firebase.google.com/docs/hosting/full-config#ignore)) that dotfiles (`public/.*`) are ignored from bein publicly served.
- The Cloud Function is named `nextjsFunc` (changeable in [firebaseFunctions.js](firebaseFunctions.js#L16) and [firebase.json](firebase.json#L8)). - The Cloud Function is named `nextjsFunc` (changeable in [firebaseFunctions.js](firebaseFunctions.js#L16) and [firebase.json](firebase.json#L8)).
- `public/*` files are statically served through [Firebase hosting](https://firebase.google.com/docs/hosting/full-config#public), not through [NextJs server](https://nextjs.org/docs/basic-features/static-file-serving). - `public/*` files are statically served through [Firebase hosting](https://firebase.google.com/docs/hosting/full-config#public), not through [NextJs server](https://nextjs.org/docs/basic-features/static-file-serving).
- Specifying [`"engines": {"node": "10"}`](package.json#L5-L7) in `package.json` is required and the [latest supported](https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version) by firebase functions.
#### Customization #### Customization
...@@ -82,11 +81,7 @@ The crucial files for the setup: ...@@ -82,11 +81,7 @@ The crucial files for the setup:
- `firebase.json` - `firebase.json`
- `firebaseFunctions.js` - `firebaseFunctions.js`
- `src/next.config.js` - `src/next.config.js`
- In `package.json`: `firebase-*` packages and `engines` field - In `package.json`: `firebase-*` packages.
## Caveat
Because firebase functions require `"engines": {"node": "10"}` (or 8) to be specified (in `package.json`), if you are using `yarn` (instead of `npm`), you will need to add flag [`--ignore-engines`](https://classic.yarnpkg.com/en/docs/cli/install/#toc-yarn-install-ignore-engines).
## References ## References
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"predeploy": [ "predeploy": [
"npm --prefix \"$PROJECT_DIR\" install", "npm --prefix \"$PROJECT_DIR\" install",
"npm --prefix \"$PROJECT_DIR\" run build" "npm --prefix \"$PROJECT_DIR\" run build"
] ],
"runtime": "nodejs10"
} }
} }
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
"name": "with-firebase-hosting", "name": "with-firebase-hosting",
"version": "5.0.0", "version": "5.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.",
"engines": {
"node": "10"
},
"main": "firebaseFunctions.js", "main": "firebaseFunctions.js",
"scripts": { "scripts": {
"dev": "next src/", "dev": "next src/",
...@@ -24,6 +21,6 @@ ...@@ -24,6 +21,6 @@
}, },
"devDependencies": { "devDependencies": {
"firebase-functions-test": "^0.1.6", "firebase-functions-test": "^0.1.6",
"firebase-tools": "^8.0.1" "firebase-tools": "^8.6.0"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment