Config
Vona loads config files based on multi-dimensional variables, providing a more flexible configuration mechanism and supporting more complex business scenarios
meta & config file
Vona loads config files from the src/backend/config/config directory and supports file loading based on meta conditions:
config.ts # loaded in all cases
config.[meta].ts # only loaded in specified condition
config.mine.ts # loaded in all cases, ignored by git
config.[meta].mine.ts # only loaded in specified condition, ignored by git[meta]can beany combinationof the following two variables
| Name | Description |
|---|---|
| mode | 'test' |'dev' | 'prod' |
| flavor | 'normal' |'demo' |'docker' | 'ci' | keyof VonaMetaFlavorExtend |
npm scripts
Corresponding to the multidimensional variables, the correspondence between the commands and the scripts are as follows:
$ npm run test
$ npm run dev
$ npm run build
$ npm run build:docker"scripts": {
"test": "vona :bin:test --flavor=normal",
"dev": "vona :bin:dev --flavor=normal",
"build": "vona :bin:build --flavor=normal",
"build:docker": "vona :bin:build --flavor=docker",
}For example
Execute npm run dev on the command line, then the corresponding meta variable values are:
| Name | Value |
|---|---|
| mode | 'dev' |
| flavor | 'normal' |
The system will automatically load the configuration in the following files and merge them:
config.ts
config.normal.ts
config.normal.dev.ts
config.mine.ts
config.normal.mine.ts
config.normal.dev.mine.tsObtaining global config
The global config object can be obtained directly through this.app.config in any bean instance
this.app.config.server.globalPrefix
this.app.config.database.defaultClientObtaining module config
Modules can individually provide their own config configuration, which can be obtained through the Scope instance. See: Config
this.scope.config.title
this.$scope.homeIndex.config.titleOverride module config
You can use project-level config to override module-level config, see: Config
src/backend/config/config/config.ts
// modules
config.modules = {
'home-index': {
title: 'Hello World!!',
},
};