https://github.com/joshdholtz/ionic-configurator
Configure Ionic (Cordova) config.xml files for individual environments using Mustache templating
https://github.com/joshdholtz/ionic-configurator
ionic-cordova ionic-framework ionic-plugin ionic3
Last synced: about 1 year ago
JSON representation
Configure Ionic (Cordova) config.xml files for individual environments using Mustache templating
- Host: GitHub
- URL: https://github.com/joshdholtz/ionic-configurator
- Owner: joshdholtz
- Created: 2018-01-27T19:34:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-28T19:14:33.000Z (about 8 years ago)
- Last Synced: 2025-03-17T05:21:55.246Z (about 1 year ago)
- Topics: ionic-cordova, ionic-framework, ionic-plugin, ionic3
- Language: JavaScript
- Size: 6.84 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ionic Configurator
Somewhat easily reconfigure Ionic's `config.xml` for different environments by running `npm run ionic-config `.
View working example: https://github.com/joshdholtz/ionic-configurator-example
## Installation
```sh
$: npm install --save-dev https://github.com/joshdholtz/ionic-configurator.git
```
## Commands
```sh
$: npm run ionic-config
```
where `` environment will look for a file `./ionic-configurator/env..json`
## Setup
### package.json
Add `ionic-config` to your `package.json` scripts. This will allow you to run `npm run ionic-config ` instead of having to run `./node_modules/.bin/ionic-config `
```json
"scripts": {
"ionic-config": "ionic-config"
}
```
### ionic-configurator/config.tmpl.xml
Create a `config.tmpl.xml` file in the `ionic-configurator` directory. This is the template `config.xml` file that all environment specific `config.xml` files will be made from.
The `config.tmpl.xml` file uses [Mustache templating](https://github.com/janl/mustache.js)
```xml
{{name}}
{{description}}
Ionic Framework Team
...
```
### Environment file
Create environment files using the pattern `env..json` in `ionic-configurator`. These keys should match up with the Mustache templating used in the `config.tmpl.xml` file.
#### ionic-configurator/env.staging.json
```json
{
"id": "com.joshholtz.staging.IonicApp",
"version": "1.1.2",
"name": "Ionic App (Staging)",
"description": "This awesome Ionic app description <3"
}
```
#### ionic-configurator/env.production.json
```json
{
"id": "com.joshholtz.IonicApp",
"version": "1.1.2",
"name": "Ionic App",
"description": "This awesome Ionic app description <3"
}
```
### ionic-configurator/hooks.js
This hooks is used when plugins are added and removed. This will temporarily move the template to `config.xml` and then back to `ionic-configurator/config.tmpl.xml` so that the plugin changes are recorded in our templated.
**NOTE:** This will keep the templated config at `config.xml` so you will need to re-run `ionic-config `
```js
#!/usr/bin/env node
module.exports = function(ctx) {
var Configurator = require('ionic-configurator');
Configurator.hook(ctx.hook);
}
```