Reputation: 23362
I've got the standard app structure for a Firebase/Angular application.
- functions/
|--- index.ts
|--- package.json
- src/
|--- app/
| |--- (angular stuff)
|--- index.html
|--- ...
- package.json
- firebase.json
The problem is that when I run firebase deploy --only functions
, the predeploy hooks that I've defined in firebase.json
, are called from inside the root/
directory, and not from inside root/functions/
directory.
So for example, in root/package.json
I have
{
"name": "functions",
"scripts": {
"echo": "echo 'hello1'"
},
...
}
but in root/functions/package.json
I have
{
"name": "functions",
"scripts": {
"echo": "echo 'hello2'"
},
...
}
and in my firebase.json
file I have
{
...
"functions": {
"predeploy": [
"npm run echo"
]
},
No matter whether I am in root/
or root/functions
, when I run firebase deploy --only functions
I get hello1
How do I configure my Firebase tools to use the configurations (i.e. namely the package.json
stuff) from functions/
when I run deploy --only functions
?
Upvotes: 2
Views: 1895
Reputation: 23362
It seems the best way to get this working, according to the Firebase Typescript docs, is to specify the predeploy
hook as follows
{
"functions": {
"predeploy": "npm --prefix functions run build",
}
}
This calls npm run build
from inside the functions
directory, so it will call the build
script in functions/package.json
and not the project root's package.json
Upvotes: 1