Deploy only what changed
Deploy just the functions you changed, or just the rules, indexes or website. A small deploy is faster, and a targeted functions deploy never deletes anything.
The quickest way is the guided deploy's first choice, "Only the functions changed since the last deploy", which works out the functions for you:
npm run deploy
The rest of this page is for deploying by name, from a script, or when that choice is not offered. Everything about the guided deploy and the flags is in Deploy.
Deploy one or a few functions
Every Arc CMS function is exported in one group, arccms, from the arccms codebase, so a function exported as search is deployed as arccms-search. The Firebase CLI names it functions:arccms:arccms.search:
npm run deploy -- --only functions:arccms:arccms.<name> --project default
Several at once, separated by commas:
npm run deploy -- --only functions:arccms:arccms.search,functions:arccms:arccms.reindexSearch --project default
| To deploy | Target | Deployed name |
|---|---|---|
| One core function | functions:arccms:arccms.<name> | arccms-<name> |
One of the app's functions (functions/src/custom/) | functions:arccms:arccms.custom.<name> | arccms-custom-<name> |
| All of the app's functions | functions:arccms:arccms.custom | |
| Every function | functions:arccms |
<name> is the name the function is exported under in the source, such as export const reindexSearch = onCall(...). The deploy builds the functions first, as always.
A targeted deploy never deletes a function. Deleting the functions of a feature you turned off, or of a search collection you removed, takes a deploy of every function (see Functions that are deleted).
Deploy only rules, indexes or the website
| To deploy | Command |
|---|---|
| Database rules and indexes | npm run deploy -- --only firestore --project default |
| Database rules only | npm run deploy -- --only firestore:rules --project default |
| Database indexes only | npm run deploy -- --only firestore:indexes --project default |
| Storage rules | npm run deploy -- --only storage --project default |
Each of these combines the core rules and indexes with the app's own before uploading (see Security rules).
For the website, deploy Hosting (the deploy builds the site for that project first), then publish the static pages again. For the default alias:
npm run deploy -- --only hosting --project default
npm run seed:dev
For another project, give its alias to both: npm run deploy -- --only hosting --project production, then npm run seed -- production. The guided deploy's "Website" choice does both steps.
I changed this, so I deploy that
| You changed | Deploy |
|---|---|
A file in functions/src/ | The functions that use it: the guided deploy's "Only the functions changed", or those functions by name |
A file in functions/src/custom/ | functions:arccms:arccms.custom |
functions/package.json, functions/package-lock.json, functions/tsconfig.json, or a .env file in functions/ | Every function (functions:arccms) |
The collections in functions/src/custom/search-sources.ts | Every function: each collection has its own trigger, and a removed one is deleted only by a deploy of every function |
src/custom/features.ts | Every function, then the website |
firestore.rules or the app's firestore.app.rules | firestore:rules |
firestore.indexes.json or the app's firestore.app.indexes.json | firestore:indexes |
storage.rules or the app's storage.app.rules | storage |
Anything in src/ or public/, index.html, vite.config.ts, package.json | The website (build, hosting, then the static pages) |
When a change touches functions, rules and the website together, mind the order: see When the order matters.
How the guided deploy finds the changed functions
Each successful deploy is recorded per project, with its git commit, in .arc-deploy-state.json in your checkout. Next time, the guided deploy:
Lists the files changed since the commit of the last functions deploy: committed changes, uncommitted changes and new files, because the deploy builds the working tree.
Builds the functions and reads which functions the build exports.
Reads the imports of every
.tsfile infunctions/src/(not specs), and which functions each file defines (export const name = onCall(...), any otheron...trigger, orbeforeUser...).Picks every function whose file, or any file it imports directly or indirectly, changed. A change in
functions/src/custom/picks the wholecustomgroup.Adds functions that are new since the last deploy, and every function it cannot find a definition for whenever any source changed.
It does not offer the choice when:
- this checkout has no recorded functions deploy for the project (the first time, or after deploying from another computer);
- a dependency, TypeScript setting or
.envfile changed, which affects every function: it says so, and "All functions" is the one to pick; - no function changed.
It also names functions that were removed from the code since the last deploy: only "All functions" deletes them from the project.
Only whole deploys are recorded: all the functions, the "changed" choice, firestore, storage or hosting. A deploy of named functions with flags is not, so the next guided deploy still counts their files as changed. That is on purpose: the other functions may still be behind.