| 4 | const APP_ROOT_VIRTUAL = getProjectAppVirtualPath(); |
| 5 | |
| 6 | export function getGlobalDefines(opts: { platform: string; targetMode: string; verbose: boolean; flavor: string; isCI?: boolean }) { |
| 7 | return { |
| 8 | // Define platform flags for runtime checks |
| 9 | __ANDROID__: JSON.stringify(opts.platform === 'android'), |
| 10 | __IOS__: JSON.stringify(opts.platform === 'ios'), |
| 11 | __VISIONOS__: JSON.stringify(opts.platform === 'visionos'), |
| 12 | __APPLE__: JSON.stringify(opts.platform === 'ios' || opts.platform === 'visionos'), |
| 13 | __DEV__: JSON.stringify(opts.targetMode === 'development'), |
| 14 | __COMMONJS__: false, |
| 15 | __NS_WEBPACK__: false, |
| 16 | __NS_ENV_VERBOSE__: JSON.stringify(opts.verbose), |
| 17 | __NS_TARGET_FLAVOR__: JSON.stringify(opts.flavor), |
| 18 | __CSS_PARSER__: JSON.stringify('css-tree'), |
| 19 | __UI_USE_XML_PARSER__: true, |
| 20 | __UI_USE_EXTERNAL_RENDERER__: false, |
| 21 | // various ecosystems use this global (react for example) |
| 22 | __TEST__: false, |
| 23 | // determine if running in CI environment |
| 24 | __CI__: JSON.stringify(!!opts.isCI), |
| 25 | __NS_APP_ROOT_DIR__: JSON.stringify(APP_ROOT_DIR), |
| 26 | __NS_APP_ROOT_VIRTUAL__: JSON.stringify(APP_ROOT_VIRTUAL), |
| 27 | // Critical for various integrations (e.g. Vue only includes hmr runtime on this condition) |
| 28 | 'process.env.NODE_ENV': JSON.stringify(opts.targetMode === 'development' ? 'development' : 'production'), |
| 29 | }; |
| 30 | } |