joshdholtz / ionic-configurator

Configure Ionic (Cordova) config.xml files for individual environments using Mustache templating

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ionic Configurator

Somewhat easily reconfigure Ionic's config.xml for different environments by running npm run ionic-config <environment>.

View working example:


$: npm install --save-dev


$: npm run ionic-config <environment>

where <environment> environment will look for a file ./ionic-configurator/env.<environment>.json



Add ionic-config to your package.json scripts. This will allow you to run npm run ionic-config <environment> instead of having to run ./node_modules/.bin/ionic-config <environment>

"scripts": {
    "ionic-config": "ionic-config"


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

<?xml version='1.0' encoding='utf-8'?>
<widget id="{{id}}" version="{{version}}" xmlns="" xmlns:cdv="">
    <!--- These hooks are used to modify the config.tmpl.xml file when plugins are added and removed  -->
    <hook src="ionic-configurator/hooks.js" type="before_plugin_add" />
    <hook src="ionic-configurator/hooks.js" type="after_plugin_add" />
    <hook src="ionic-configurator/hooks.js" type="before_plugin_rm" />
    <hook src="ionic-configurator/hooks.js" type="after_plugin_rm" />
    <author email="hi@ionicframework" href="">Ionic Framework Team</author>
    <content src="index.html" />

Environment file

Create environment files using the pattern env.<environment>.json in ionic-configurator. These keys should match up with the Mustache templating used in the config.tmpl.xml file.


  "id": "com.joshholtz.staging.IonicApp",
  "version": "1.1.2",
  "name": "Ionic App (Staging)",
  "description": "This awesome Ionic app description <3"


  "id": "com.joshholtz.IonicApp",
  "version": "1.1.2",
  "name": "Ionic App",
  "description": "This awesome Ionic app description <3"


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 <environment>

#!/usr/bin/env node
module.exports = function(ctx) {
  var Configurator = require('ionic-configurator');
ezoic increase your site revenue


Configure Ionic (Cordova) config.xml files for individual environments using Mustache templating


Language:JavaScript 100.0%