proper productionize project

This commit is contained in:
2026-07-15 23:54:53 -07:00
parent b8850c87a4
commit edb6d2b5b4
46 changed files with 11346 additions and 1560 deletions
+25 -1
View File
@@ -1,3 +1,27 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({ plugins: [react()] })
import { readFileSync } from 'node:fs'
// A new URL makes the browser check and stage every deployed service worker.
// The waiting worker is still activated explicitly by the user in the console.
const pwaBuildId = Date.now().toString(36)
const serviceWorkerSource = readFileSync(new URL('./pwa/control-sw.js', import.meta.url), 'utf8')
export default defineConfig({
plugins: [
react(),
{
name: 'control-pwa-assets',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'control/sw.js',
source: serviceWorkerSource.replaceAll('__PWA_BUILD_ID__', pwaBuildId),
})
},
},
],
define: {
__PWA_BUILD_ID__: JSON.stringify(pwaBuildId),
},
})