我有一个这样结构的工作区,其中“app”通常是“functions”文件夹firebase init
server
--- app
------ controllers
------ middleware
------ db.js
------ index.js //where I export the firebase endpoint
------ router.js
------ serve.js //the express app
--- dist
--- node_modules
--- firebase.json
--- package.json
我可以firebase serve
从根目录运行以在本地提供功能,但firebase deploy
需要我将 package.json 文件和./dist
文件夹都放在app
.
有没有办法从根目录部署,而不将 package.json 和./dist
文件夹放在应用程序中?
我的 package.json 文件:
{
"main": "./dist/index.js",
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"prepare": "rm -rf dist && babel ./app/ -d ./dist && mkdir dist/private && cp app/private/conf.json dist/private/conf.json",
"lint": "eslint app",
"serve": "firebase serve --only dist",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only dist",
"logs": "firebase functions:log"
},
"dependencies": {
"cors": "^2.8.4",
"cross-fetch": "^2.1.0",
"firebase-admin": "^5.12.1",
"firebase-functions": "^1.0.3",
"moment": "^2.22.1",
"uuid": "^3.2.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-runtime": "^6.26.0",
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
我的 firebase.json 文件
{
"functions": {
"predeploy": [
"npm --prefix $RESOURCE_DIR run lint"
],
"source": "dist"
}
}