Skip to content

Commit

Permalink
feat(main): reduce apple icons to a single file size
Browse files Browse the repository at this point in the history
A single icon file should be sufficient to use for most use cases on Apple devices according to
Lighthouse and Webhint docs.

BREAKING CHANGE: Generated Apple touch icons is reduced to one icon. The icon file type is set to
PNG as default type, rather than a JPEG type.

fix #433
  • Loading branch information
onderceylan committed Nov 30, 2020
1 parent 620d2be commit a4a9b77
Show file tree
Hide file tree
Showing 30 changed files with 34 additions and 310 deletions.
326 changes: 28 additions & 298 deletions src/__snapshots__/main.test.ts.snap

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
13 changes: 4 additions & 9 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export default {
'https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/',

// Apple platform specs: https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/app-icon/
APPLE_ICON_SIZES: [180, 167, 152, 120],
// https://web.dev/apple-touch-icon/
APPLE_ICON_SIZES: [180],

// Android platform specs: https://developers.google.com/web/fundamentals/web-app-manifest/#icons
// Windows platform specs: https://docs.microsoft.com/en-us/microsoft-edge/progressive-web-apps/get-started
Expand Down Expand Up @@ -221,14 +222,8 @@ export default {
</body>
</html>`,

APPLE_TOUCH_ICON_META_HTML: (
size: number,
url: string,
xhtml: boolean,
): string =>
`<link rel="apple-touch-icon" sizes="${size}x${size}" href="${url}"${
xhtml ? ' /' : ''
}>
APPLE_TOUCH_ICON_META_HTML: (url: string, xhtml: boolean): string =>
`<link rel="apple-touch-icon" href="${url}"${xhtml ? ' /' : ''}>
`,

APPLE_LAUNCH_SCREEN_META_HTML: (
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ const generateAppleTouchIconHtml = (
.filter((image) =>
image.name.startsWith(constants.APPLE_ICON_FILENAME_PREFIX),
)
.map(({ width, path, name }) =>
.map(({ path, name }) =>
constants.APPLE_TOUCH_ICON_META_HTML(
width,
generateOutputPath(options, name, path),
options.xhtml,
),
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/puppets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const saveImages = async (
return Promise.all(
imageList.map(async ({ name, width, height, scaleFactor, orientation }) => {
const { quality } = options;
const type = name.includes('manifest') ? 'png' : options.type;
const type = name.includes('icon') ? 'png' : options.type;
const path = file.getImageSavePath(name, output, type);

try {
Expand Down

0 comments on commit a4a9b77

Please sign in to comment.