**Integrate PWA asset generator and update favicon and manifest configuration**

This commit is contained in:
geoffsee
2025-07-01 15:02:15 -04:00
committed by Geoff Seemueller
parent 3901337163
commit c0428094c8
20 changed files with 90 additions and 29 deletions

View File

@@ -7,10 +7,15 @@ import { VitePWA } from 'vite-plugin-pwa';
// eslint-disable-next-line import/no-unresolved
import { configDefaults } from 'vitest/config';
import { getColorThemes } from './src/layout/theme/color-themes';
const prebuildPlugin = () => ({
name: 'prebuild',
config(config, { command }) {
if (command === 'build') {
console.log('Generate PWA Assets -> public/');
child_process.execSync('bun generate:pwa:assets');
console.log('Generated Sitemap -> public/sitemap.xml');
child_process.execSync('bun generate:sitemap');
console.log('Generated Sitemap -> public/sitemap.xml');
child_process.execSync('bun run generate:robotstxt');
@@ -25,6 +30,13 @@ const prebuildPlugin = () => ({
},
});
// eslint-disable-next-line @typescript-eslint/no-require-imports
// const PROJECT_SOURCES_HASH = sha512Dir('./src');
//
// console.log({ PROJECT_SOURCES_HASH });
const buildId = crypto.randomUUID();
export default defineConfig(({ command }) => {
return {
mode: 'production',
@@ -43,16 +55,52 @@ export default defineConfig(({ command }) => {
filename: 'service-worker.js',
devOptions: {
enabled: false,
navigateFallback: 'index.html',
suppressWarnings: true,
type: 'module',
},
manifest: {
name: 'open-gsio',
name: `open-gsio`,
short_name: 'open-gsio',
description: 'Assistant',
display: 'standalone',
description: `open-gsio client`,
theme_color: getColorThemes().at(0)?.colors.text.accent,
background_color: getColorThemes().at(0)?.colors.background.primary,
scope: '/',
start_url: '/',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,wasm}'],
navigateFallbackDenylist: [/^\/api\//],
maximumFileSizeToCacheInBytes: 25000000,
cacheId: buildId,
cleanupOutdatedCaches: true,
clientsClaim: true,
},
}),
// PWA plugin saves money on data transfer by caching assets on the client