- Configure VitePWA with manifest, icons and service worker - Add PwaInstallBanner component for install prompt in header - Enable CORS for z590.interno.com access - Use dynamic hostname for terminal WebSocket connection - Add generate-icons script with sharp for PWA icons - Fix theme-color to match header background
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import sharp from 'sharp'
|
|
import { readFileSync, mkdirSync } from 'fs'
|
|
import { dirname, join } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const iconsDir = join(__dirname, '../public/icons')
|
|
|
|
// Read SVG
|
|
const svgBuffer = readFileSync(join(iconsDir, 'icon.svg'))
|
|
|
|
// Generate icons
|
|
const sizes = [
|
|
{ name: 'icon-192.png', size: 192 },
|
|
{ name: 'icon-512.png', size: 512 },
|
|
{ name: 'icon-maskable-512.png', size: 512 }
|
|
]
|
|
|
|
async function generate() {
|
|
for (const { name, size } of sizes) {
|
|
await sharp(svgBuffer)
|
|
.resize(size, size)
|
|
.png()
|
|
.toFile(join(iconsDir, name))
|
|
console.log(`Generated ${name}`)
|
|
}
|
|
|
|
// Also generate apple-touch-icon
|
|
await sharp(svgBuffer)
|
|
.resize(180, 180)
|
|
.png()
|
|
.toFile(join(iconsDir, 'apple-touch-icon.png'))
|
|
console.log('Generated apple-touch-icon.png')
|
|
|
|
// Favicon
|
|
await sharp(svgBuffer)
|
|
.resize(32, 32)
|
|
.png()
|
|
.toFile(join(__dirname, '../public/favicon.png'))
|
|
console.log('Generated favicon.png')
|
|
}
|
|
|
|
generate().catch(console.error)
|