UNPKG

@zubridge/electron

Version:

A streamlined state management library for Electron applications using Zustand.

20 lines (19 loc) 956 B
/** * Determines if the application is running in development mode * * Uses a combination of checks to ensure consistent behavior: * 1. Checks if app is packaged (production builds are packaged) * 2. Checks NODE_ENV environment variable * 3. Checks ELECTRON_IS_DEV environment variable (set by electron-is-dev or similar utilities) * * @returns {boolean} True if running in development mode, false otherwise */ export const isDev = async () => { // Ensure we have access to the app object (should be in the main process) const { app } = await import('electron'); if (typeof app !== 'undefined') { return !app.isPackaged || process.env.NODE_ENV === 'development' || process.env.ELECTRON_IS_DEV === '1'; } // Fallback for renderer process or when app isn't available return (process.env.NODE_ENV === 'development' || process.env.ELECTRON_IS_DEV === '1' || !process.env.VITE_DEV_SERVER_URL); // Vite-specific check };