Skip to content

Commit

Permalink
Simplify maskable icon processing checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronrr committed Feb 12, 2021
1 parent 66c4b60 commit 7257b49
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/files/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ export const createManifest = async (context, config, queue, options) => {

// maskableIcon can now be boolean or an icon path.
// if it is true, or is the same icon file as standard icon, set 'maskable any'
// also revert maskableIconName to null, as we won't need to process separately
if (options.maskableIcon === true || options.maskableIcon === options.icon) {
purpose = 'maskable any'
maskableIconName = null
}

// add and process { icon }
icons.push({src, type, sizes, purpose});
const results = [sharp(options.icon).resize(size, size).toFile(imagePath)]

// if maskableIcon is a string, then we need to process it as a separate maskable icon
if (options.maskableIcon && typeof options.maskableIcon === 'string') {
if (maskableIconName) {
imagePath = path.join(iconsDir, rename(maskableIconName, { suffix: `-maskable-${sizes}` }))
src = path.relative(config.outputDir, imagePath);
type = 'image/' + maskableIconName.split('.').slice(-1)[0];
Expand Down

0 comments on commit 7257b49

Please sign in to comment.