Skip to content

Commit

Permalink
feat: multi firebase.json
Browse files Browse the repository at this point in the history
Get some turbo benefits but lose the ability to iterate on functions in a Backend for Frontend in locally together with the frontend.
  • Loading branch information
yamcodes committed Mar 30, 2024
1 parent 556ab86 commit b77d9e3
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 24 deletions.
File renamed without changes.
19 changes: 19 additions & 0 deletions apps/api/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"functions": [
{
"source": ".",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"isolate": true
}
],
"emulators": {
"functions": {
"port": 3001
}
}
}
8 changes: 5 additions & 3 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
},
"scripts": {
"dev": "vite build --watch",
"emulate": "firebase emulators:start --only functions",
"deploy": "firebase deploy --only functions",
"build": "rimraf dist && vite build",
"lint": "eslint --ext .js,.ts .",
"build:watch": "tsc --watch",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"clean": "rimraf node_modules dist isolate"
},
Expand All @@ -29,12 +30,12 @@
"main": "dist/index.js",
"dependencies": {
"@faker-js/faker": "^8.0.1",
"@google-cloud/functions-framework": "^3.3.0",
"express": "^4.18.2",
"fastify": "^4.26.2",
"firebase-admin": "^12.0.0",
"firebase-functions": "^4.8.1",
"utilities": "workspace:*",
"@google-cloud/functions-framework": "^3.3.0"
"utilities": "workspace:*"
},
"devDependencies": {
"@types/rollup-plugin-generate-package-json": "^3.2.0",
Expand All @@ -44,6 +45,7 @@
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"firebase-functions-test": "^3.1.0",
"firebase-tools-with-isolate": "^13.4.0",
"rimraf": "^5.0.1",
"rollup-plugin-generate-package-json": "^3.2.0",
"typescript": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const registerRoutes = (fastify: FastifyInstance) => {

fastify.get('*', (_req, res) => {
void res.send({
hello: 'world!',
hello: 'world!!!',
randomName: faker.person.firstName(),
iLikeTurtles: iLikeTurtles(),
nice: 69,
Expand Down
5 changes: 5 additions & 0 deletions apps/web/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "turborepo-demo-74599"
}
}
6 changes: 1 addition & 5 deletions firebase.json → apps/web/firebase.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"functions": [
{
"source": "apps/api",
"codebase": "default",
"source": "../api",
"ignore": [
"node_modules",
".git",
Expand All @@ -27,9 +26,6 @@
]
},
"emulators": {
"functions": {
"port": 3001
},
"hosting": {
"enabled": true,
"port": 3002
Expand Down
4 changes: 3 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"emulate": "firebase emulators:start --only hosting",
"deploy": "firebase deploy --only hosting",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"deploy": "firebase deploy --only hosting",
"clean": "rimraf node_modules dist"
},
"dependencies": {
Expand All @@ -20,6 +21,7 @@
"@types/react-dom": "^18.2.4",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.41.0",
"firebase-tools-with-isolate": "^13.4.0",
"vite": "^5.0.0"
}
}
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
"type": "module",
"scripts": {
"start": "turbo run dev emulators",
"dev": "turbo run build && turbo run root:emulate dev",
"dev": "turbo run emulate dev",
"clean": "turbo run root:clean clean",
"build": "turbo run build",
"deploy": "turbo run deploy",
"lint": "pnpm format:check && turbo run lint",
"lint:fix": "pnpm format && turbo run lint -- --fix",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\"",
"root:clean": "rimraf node_modules",
"root:emulate": "firebase emulators:start"
"root:clean": "rimraf node_modules"
},
"devDependencies": {
"eslint-config-custom": "workspace:*",
"firebase-tools-with-isolate": "^13.4.0",
"prettier": "^3.0.0",
"tsconfig": "workspace:*",
"turbo": "^1.13.0",
Expand Down
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
"cache": false,
"persistent": true
},
"emulate": {
"dependsOn": ["build"],
"cache": false,
"persistent": true
},
"clean": {
"cache": false
},
"//#root:clean": {
"cache": false
},
"//#root:emulate": {
"cache": false,
"persistent": true
}
}
}

0 comments on commit b77d9e3

Please sign in to comment.