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 deployTargetDeployed name
One core functionfunctions: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 functionsfunctions:arccms:arccms.custom
Every functionfunctions: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 deployCommand
Database rules and indexesnpm run deploy -- --only firestore --project default
Database rules onlynpm run deploy -- --only firestore:rules --project default
Database indexes onlynpm run deploy -- --only firestore:indexes --project default
Storage rulesnpm 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 changedDeploy
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.tsEvery function: each collection has its own trigger, and a removed one is deleted only by a deploy of every function
src/custom/features.tsEvery function, then the website
firestore.rules or the app's firestore.app.rulesfirestore:rules
firestore.indexes.json or the app's firestore.app.indexes.jsonfirestore:indexes
storage.rules or the app's storage.app.rulesstorage
Anything in src/ or public/, index.html, vite.config.ts, package.jsonThe 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:

  1. 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.

  2. Builds the functions and reads which functions the build exports.

  3. Reads the imports of every .ts file in functions/src/ (not specs), and which functions each file defines (export const name = onCall(...), any other on... trigger, or beforeUser...).

  4. Picks every function whose file, or any file it imports directly or indirectly, changed. A change in functions/src/custom/ picks the whole custom group.

  5. 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:

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.