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.
3 Answers
Reset to default 4By 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条)