pwa-asset-generator
pwa-asset-generator copied to clipboard
Generate ONLY iOS or ONLY Android icons
- My iOS icons should have a white background
- My Android icon should have a transparent background
I'm currently using this script.
pwa.js
const { generateImages } = require('pwa-asset-generator');
const { rename } = require('fs').promises;
const pwaArgs = ['dist/logo.png', 'dist/images'];
const appleIcon = 'apple-icon-180.png';
const manifest = 'dist/manifest.json'; // Write to manifest.json
const index = ''; // Do not write to index.html
// Or you could read parameters from process.argv
(async () => {
console.log('Generating Apple icon...');
await generateImages(...pwaArgs, {
background: '#227',
iconOnly: true,
log: false
});
console.log('Storing Apple icon...');
await rename('dist/images/' + appleIcon, 'dist/' + appleIcon);
console.log('Generating transparent icons...');
await generateImages(...pwaArgs, {
...(manifest && { manifest }),
...(index && {index}),
opaque: false,
favicon: true,
mstile: true,
log: false
});
// TODO: Reprettify index.html
console.log('Replacing Apple icon...');
await rename('dist/' + appleIcon, 'dist/images/' + appleIcon);
console.log('Generating Apple splash screens...');
await generateImages(...pwaArgs, {
background: '#227',
splashOnly: true,
log: false
});
console.log('Completed.');
})();
package.json
{
"scripts": {
"generate-pwa-asset": "node pwa.js"
}
}