#$production and staging

3 messages · Page 1 of 1 (latest)

barren sundial
#

Hello Kapa

In somt Nuxt Scripts analytics you can find a $production to add them only in production : https://scripts.nuxt.com/scripts/analytics/umami-analytics
However, I have "production" as a preproduction deployed too, which I would like to not be considered as a production.

Is the siteEnv in runtimeConfig set to staging will ensure that $production is not used, or it has nothing to do with it ?

red nacelleBOT
#

Hi @barren sundial. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

There’s no explicit information in the knowledge sources about $production in Nuxt Scripts (e.g. Umami Analytics) being affected by runtimeConfig.siteEnv, or by any custom runtime config key.

From the docs and videos we do have, environment‑specific config in Nuxt is driven by the build/runtime environment (via C12) and the standard environments development, production, and test, not by arbitrary runtimeConfig values. The $production, $development, $test blocks in nuxt.config are selected based on that environment, not on something like runtimeConfig.siteEnv.😲 Env-aware config

So, based on the available sources:

  • $production is tied to Nuxt’s notion of the environment (i.e. NODE_ENV / C12 env), not to runtimeConfig.siteEnv.
  • Setting runtimeConfig.siteEnv = 'staging' will not by itself prevent $production blocks from being applied, if Nuxt is running in production mode.

If you need different behavior for “real production” vs “preproduction but still built as production”, the knowledge sources don’t show a built‑in way to make $production distinguish those two. You’d likely need a separate mechanism (e.g. a different env var that your own code checks), but I don’t have concrete Nuxt Scripts examples for that in the provided material, so I can’t give a precise pattern without going beyond the sources.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: