Generates cordova config.xml file
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-cordova-config --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-cordova-config');
In your project's Gruntfile, add a section named cordova_config
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
cordova_config: {
my_target: {
options : {
id : 'com.example.hello',
version : '1.0.0',
// ...
},
dest : 'path/to/config.xml
}
},
})
Type: String
Default value: com.example.hello
Type: String
Default value: 0.0.1
Type: Number
(optional)
Can be used to override the default code calculated by Cordova as PATCH + MINOR * 100 + MAJOR * 10000
Type: String
(optional)
Can be used to override the default code generated by Cordova as "MAJOR.MINOR.PATCH"
Type: String
Default value: HelloWorld
Type: String
Default value: A sample Apache Cordova application that responds to the deviceready event.
Type: String
Default value: Apache Cordova Team
Type: String
Default value: dev@callback.apache.org
Type: String
Default value: http://cordova.io
Type: String
Default value: index.html
Type: String
Default value: *
Type: Array
of (Preference objects)
Example:
preferences: [
{
name : 'fullscreen',
value: true
},
{
name : 'webviewbounce',
value: false
},
...
Default value: []
Type: Array
Example:
features : [
{
name : 'StatusBar',
params: [
{
name : 'ios-package',
value : 'CDVStatusBar',
onload: true
}
]
}
]
Default value: []
Type: Array
of (Image objects)
References images from which Cordova can generate appropriately-sized icons for each platform. This is particularly useful for early prototypes for which platform-specific icons have not yet been created. See also the icons
attribute in options.platforms
.
Example:
icons : [
{
src : 'res/icon-1024.png'
}
]
Default value: []
Type: Array
of (Platform objects)
Example:
platforms : [
{
name : 'ios',
icons: [
{
src : 'res/Icon-60.png',
width : 60,
height: 60
}
],
splash: [
{
src : 'res/Default.png',
width : 320,
height: 480
}
],
preferences: [
{
fullscreen: false
}
]
},
{
name : 'android',
icons: [
{
src : 'res/icon-hdpi.png',
density: 'hdpi'
}
]
}
]
Type: String
Type: any
Please refer to the Cordova/PhoneGap Icons and Splash Screens documentation for usage. Generally, Android requires the density
parameter while other platforms either use width
and height
or require a specific image name.
Type: String
Type: String
(optional)
Type: Number
(optional)
Type: Number
(optional)
Type: String
(optional)
For use in option.icons
, though specifying icons in the platforms
array may be preferable.
Type: String
Type: Array
of (Image objects)
Type: Array
of (Image objects)
Type: Array
of (Preference objects)
In this example, the default options are used to generate config.xml file. The result will be the same as after cordova create
command
grunt.initConfig({
cordova_config: {
my_target : {
dest: 'cordova-project/www/config.xml'
}
},
})
grunt.initConfig({
cordova_config: {
options: {
id: 'com.example.application',
name: 'app name',
author : {
name : 'First Last',
email : 'email@example.com'
},
preferences: [
{
name : 'fullscreen',
value: true
},
{
name : 'webviewbounce',
value: false
},
{
name : 'UIWebViewBounce',
value: false
},
{
name : 'DisallowOverscroll',
value: true
},
{
name : 'BackupWebStorage',
value: 'none'
}
],
features : [
{
name : 'StatusBar',
params: [
{
name : 'ios-package',
value : 'CDVStatusBar',
onload: true
}
]
}
],
icons : [
{
src : 'icon-default.png'
}
],
platforms : [
{
name : 'ios',
icons: [
{
src : 'res/Icon-60.png',
width : 60,
height: 60
}
],
splash: [
{
src : 'res/Default.png',
width : 320,
height: 480
}
],
preferences: [
{
fullscreen: false
}
]
}
]
},
dest : 'cordova-project/www/config.xml'
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Copyright (c) 2014 Andrey Shustariov. Licensed under the MIT license.