All files / src/utils isDevBuild.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 222x                                     2x 2x  
/**
 * Build-mode flag derived from Vite's `import.meta.env.MODE`.
 *
 * `true` for any non-production Vite build: the dev server (`pnpm dev`),
 * `--mode=development`, `--mode=aggregate`, `--mode=mock`, and Vitest
 * (which uses `MODE === "test"`). `false` only for `--mode=production`
 * (i.e. `pnpm build:prod`).
 *
 * Vite replaces `import.meta.env.MODE` with a string literal at build time,
 * so downstream `if (!IS_DEV_BUILD)` branches collapse to dead code in prod
 * and are removed by Rollup's tree-shaking.
 *
 * @category Utils
 * @example
 * ```ts
 * import { IS_DEV_BUILD } from "@/utils/isDevBuild";
 * if (IS_DEV_BUILD) { console.debug("only fires in dev"); }
 * ```
 * @source
 */
export const IS_DEV_BUILD = import.meta.env.MODE !== 'production';