Files
MulliganMates/scripts/generate-icons.mjs
T
2026-03-18 12:39:48 +01:00

27 lines
1011 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import sharp from 'sharp'
import { readFileSync } from 'fs'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const root = join(__dirname, '..')
const icon = readFileSync(join(root, 'public/icons/icon.svg'))
const maskable = readFileSync(join(root, 'public/icons/icon-maskable.svg'))
await sharp(icon) .resize(192, 192).png().toFile(join(root, 'public/icons/icon-192.png'))
await sharp(icon) .resize(512, 512).png().toFile(join(root, 'public/icons/icon-512.png'))
await sharp(maskable) .resize(512, 512).png().toFile(join(root, 'public/icons/icon-512-maskable.png'))
// Apple touch icon (180×180, no transparency — white bg for iOS)
await sharp(icon)
.resize(180, 180)
.flatten({ background: '#ffffff' })
.png()
.toFile(join(root, 'public/icons/apple-touch-icon.png'))
// Favicon (32×32)
await sharp(icon).resize(32, 32).png().toFile(join(root, 'public/favicon.png'))
console.log('Icons generated.')