Skip to content

Latest commit

 

History

History
45 lines (37 loc) · 1.2 KB

File metadata and controls

45 lines (37 loc) · 1.2 KB

OpenCore CLI v1.4.0

Feature — Environment System

Angular-style environment support without touching files on disk. esbuild resolves the correct file at build time via aliases.

CLI flags

  • opencore build --environment production (shorthand -e)
  • opencore dev --environment development
  • Priority: flag > OPENCORE_ENVIRONMENT env var > build.environment in config > development

Per-environment build overrides

build: {
  environments: {
    production: {
      minify: true,
      sourceMaps: false,
      logLevel: 'ERROR',
      fileReplacements: [
        { replace: './src/config/api.ts', with: './src/config/api.prod.ts' },
      ],
    },
  },
}

Usage in resources

import { environment } from '@opencore/environment'

if (!environment.production) {
  logger.debug('...')
}

Project structure (generated by opencore init)

environments/
├── environment.model.ts        # Define your AppEnvironment interface here
├── environment.development.ts
└── environment.production.ts

Validation — if environments/ exists but the requested environment file is missing, the build fails with the list of available environments.