electron.vite.config.ts2.1 KBView on GitHub
import { defineConfig } from 'electron-vite'
import { resolve } from 'path'

// Map NODE_ENV values to the two known Cedar environments.
// 'development' / 'local' / anything else → treat as production for URL resolution.
const rawEnv = process.env['NODE_ENV'];
const env: 'production' | 'staging' = rawEnv === 'staging' ? 'staging' : 'production';

const CEDAR_URLS = {
  production: 'https://mail.cedarcopilot.com',
  staging: 'https://mail-staging.cedarcopilot.com',
} as const

const alias = { '@': resolve('src') }

// Meeting recording (Recall.ai SDK, the detection popup, the in-call UI and the
// calendar auto-join) is OFF unless CEDAR_RECORDING=1 at build time. The desktop
// app is otherwise just the web app in a native shell.
//
// This is not only a product switch. @recallai/desktop-sdk ships a ~335MB
// GStreamer.framework whose nested Mach-O binaries could not be signed reliably
// in CI, which is what has been failing notarization since April. When the flag
// is off the package is excluded from the bundle (see electron-builder.config.js)
// and must never be require()d — hence the lazy loader in services/recallSdk.ts.
const recordingEnabled = process.env['CEDAR_RECORDING'] === '1'

export default defineConfig({
  main: {
    resolve: { alias },
    build: {
      rollupOptions: {
        external: ['@recallai/desktop-sdk'],
      },
    },
    define: {
      __CEDAR_URL__: JSON.stringify(CEDAR_URLS[env]),
      __RECORDING_ENABLED__: JSON.stringify(recordingEnabled),
      __CEDAR_ENV__: JSON.stringify(env),
      __DESKTOP_UPDATE_KEY__: JSON.stringify(process.env['DESKTOP_UPDATE_KEY'] ?? ''),
      __RECALL_API_URL__: JSON.stringify(
        process.env['RECALL_API_URL'] ?? 'https://us-west-2.recall.ai'
      ),
    },
  },
  preload: {
    resolve: { alias },
    define: {
      __RECORDING_ENABLED__: JSON.stringify(recordingEnabled),
    },
    build: {
      rollupOptions: {
        input: {
          index: resolve('src/preload/index.ts'),
          popup: resolve('src/preload/popup.ts'),
          call:  resolve('src/preload/call.ts'),
        },
      },
    },
  },
})