Configuration
Files
Configuration values are stored in JSON files. The Ionic CLI maintains a global configuration file, usually located at ~/.ionic/config.json
, and project configuration files, usually at the project's root directory as ionic.config.json
.
The CLI provides commands for setting and printing config values from project config files and the global CLI config file. See ionic config --help
or see the documentation for usage of ionic config get
and ionic config set
.
Project Configuration File
Each Ionic project has a project configuration file, usually at the project's root directory. The following is an annotated ionic.config.json
file.
{
// The human-readable name of the app.
"name": "My App",
// The project type of the app. The CLI uses this value to determine which
// commands and command options are available, what to output for help
// documentation, and what to use for web asset builds and the dev server.
"type": "angular",
// The App ID for Appflow.
"id": "abc123",
// Configuration object for integrations such as Cordova and Capacitor.
"integrations": {
"cordova": {
...
}
},
// Hook configuration--see the Hooks section below for details.
"hooks": {
...
}
}
Environment Variables
The CLI will look for the following environment variables:
IONIC_CONFIG_DIRECTORY
: The directory of the global CLI config. Defaults to~/.ionic
.IONIC_HTTP_PROXY
: Set a URL for proxying all CLI requests through. See Using a Proxy.IONIC_TOKEN
: Automatically authenticates with Appflow.
Flags
CLI flags are global options that alter the behavior of a CLI command.
--help
: Instead of running the command, view its help page.--verbose
: Show all log messages for debugging purposes.--quiet
: Only showWARN
andERROR
log messages.--no-interactive
: Turn off interactive prompts and fancy outputs. If CI or a non-TTY terminal is detected, the CLI is automatically non-interactive.--confirm
: Turn on auto-confirmation of confirmation prompts. Careful: the CLI prompts before doing something potentially harmful. Auto-confirming may have unintended results.
Hooks
The CLI can run scripts during certain events, such as before and after builds. To hook into the CLI, the following npm scripts can be used in package.json
:
ionic:serve:before
: executed before the dev server startsionic:serve:after
: executed after the dev server is terminatedionic:build:before
: executed before a web asset build beginsionic:build:after
: executed after a web asset build finishesionic:capacitor:run:before
: executed duringionic capacitor run
before capacitor open is executedionic:capacitor:build:before
: executed duringionic capacitor build
before capacitor open is executedionic:capacitor:sync:after
: executed duringionic capacitor sync
after a sync
When using a shell script for any of the hooks, hook context is defined in environment variables prefixed with IONIC_CLI_HOOK_CTX_
.
The following example shows the environment variables that are set for the ionic:capacitor:build
hook.
IONIC_CLI_HOOK_CTX_NAME=capacitor:build:before
IONIC_CLI_HOOK_CTX_BUILD_CORDOVA_ASSETS=true
IONIC_CLI_HOOK_CTX_BUILD_ENGINE=browser
IONIC_CLI_HOOK_CTX_BUILD_PROJECT=app
IONIC_CLI_HOOK_CTX_BUILD_TYPE=angular
IONIC_CLI_HOOK_CTX_BUILD_VERBOSE=false
IONIC_CLI_HOOK_CTX_CAPACITOR_APP_ID=io.ionic.starter
IONIC_CLI_HOOK_CTX_CAPACITOR_APP_NAME=ionic-starter-app
IONIC_CLI_HOOK_CTX_CAPACITOR_VERBOSE=false