Pwa support, maybe
This commit is contained in:
18
scripts/generate-pwa-icons.mjs
Normal file
18
scripts/generate-pwa-icons.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { chromium } from '@playwright/test'
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..')
|
||||
const source = await readFile(path.join(root, 'public/app-icon.svg'), 'utf8')
|
||||
const browser = await chromium.launch({ headless: true })
|
||||
|
||||
try {
|
||||
for (const [file, size] of [['apple-touch-icon.png', 180], ['pwa-192.png', 192], ['pwa-512.png', 512]]) {
|
||||
const page = await browser.newPage({ viewport: { width: size, height: size }, deviceScaleFactor: 1 })
|
||||
await page.setContent(`<style>html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#0b0d12}svg{display:block;width:100%;height:100%}</style>${source}`)
|
||||
await page.screenshot({ path: path.join(root, 'public', file), omitBackground: false })
|
||||
await page.close()
|
||||
}
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
Reference in New Issue
Block a user