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_ENVIRONMENTenv var >build.environmentin 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.