generate-cordova-assets
Automatically generate assets for a Cordova based project.
This provides a Cordova hook which can automatically generate icons and splash screens from a single source.
Installation
npm install generate-cordova-assets --save-dev
Usage
Cordova Hook
This project comes with a Cordova hook that generates pixel perfect icons and splash screens from one icon.
This is best put in the after_prepare
hook. This means that the hook will overwrite images after Cordova has copied its default images.
For more info, see the Cordova documentation about icons and splash screens.
Preference configuration options
Name | Description |
---|---|
IconSource | The source icon to read. |
IconBackgroundColor | The color to use to fill the color for images that may not be transparent. |
Example
Add the following configurations to the config.xml file in your Cordova project:
CLI Tool
The CLI tool may be used to convert an icon to an output icon of a given width, height and background color. This may be useful to create assets for uploading to Google Play or the App Store.
For options, run:
./node_modules/.bin/process-icon --help
NodeJS
The NodeJS API may be used. However, it is not the main API and it is not guaranteed to stay the same in the forseeable future.
FAQ
Why not any of the other hooks on npm?
The other hooks I found don't support SVG or splash screens or require extra configurations.
Why are legacy launch images used for iOS?
There are two methods of defining splash images docs.
- Legacy launch images.
- Launch storyboard images.
Cordova defaults to the legacy launch images, when nothing is specified in config.xml.