javascript - How to let Firebase functions find index.js from another directory? - Stack Overflow

I'm using firebase functions with typescript similar to this instruction. However, I want to keep

I'm using firebase functions with typescript similar to this instruction. However, I want to keep all tsc pilation result in a separate build folder, so after tsc my project folder look like this:

myApp
 |__ functions
      |__ src/index.ts
      |__ build/src/index.js

How can I let firebase find build/src/index.js instead of ./index.js? There doesn't seem to be a firebase deploy option for this.

Currently I have to cp build/src/index.js . in my npm scripts but it feels like a hack.

I'm using firebase functions with typescript similar to this instruction. However, I want to keep all tsc pilation result in a separate build folder, so after tsc my project folder look like this:

myApp
 |__ functions
      |__ src/index.ts
      |__ build/src/index.js

How can I let firebase find build/src/index.js instead of ./index.js? There doesn't seem to be a firebase deploy option for this.

Currently I have to cp build/src/index.js . in my npm scripts but it feels like a hack.

Share Improve this question asked Oct 11, 2017 at 21:06 swangswang 5,2595 gold badges36 silver badges58 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

By default, Firebase looks in the functions/ folder for the source code but you can specify another folder by adding the following lines in firebase.json:

"functions": {
  "source": "another-folder"
}

Reference: https://firebase.google./docs/functions/manage-functions

THere's currently no option to specify a different output folder for Functions, like you can for Hosting. So instead of this, you probably need to put your .ts files into a different folder (e.g. myApp/functions_src) and tell tsc to output the piled versions into myApp/functions by using --outdir ./functions as described here.

Firebase actually uses the main field from your functions/package.json file, you just have to update it with the correct piled path:

{
  "main": "build/src/index.js"
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745297244a4621219.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信