pwa-asset-generator icon indicating copy to clipboard operation
pwa-asset-generator copied to clipboard

Generate ONLY iOS or ONLY Android icons

Open husk-9 opened this issue 3 years ago • 1 comments

  • My iOS icons should have a white background
  • My Android icon should have a transparent background

husk-9 avatar Aug 12 '21 04:08 husk-9

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"
  }
}

uahnbu avatar Aug 30 '21 19:08 uahnbu