switch to PWA injectManifest strategy

This commit is contained in:
ChaosExAnima 2025-04-22 16:25:52 +02:00
parent 6ac26c81f4
commit 46be26012d
No known key found for this signature in database
GPG Key ID: 8F2B333100FB6117

View File

@ -66,8 +66,6 @@ const config: UserConfigFnPromise = async ({ mode, command }) => {
}, },
build: { build: {
commonjsOptions: { transformMixedEsModules: true }, commonjsOptions: { transformMixedEsModules: true },
outDir: path.resolve(__dirname, '.dist'),
emptyOutDir: true,
manifest: 'manifest.json', manifest: 'manifest.json',
sourcemap: true, sourcemap: true,
rollupOptions: { rollupOptions: {
@ -118,7 +116,9 @@ const config: UserConfigFnPromise = async ({ mode, command }) => {
MastodonServiceWorkerLocales(), MastodonServiceWorkerLocales(),
VitePWA({ VitePWA({
srcDir: 'mastodon/service_worker', srcDir: 'mastodon/service_worker',
filename: 'sw.js', strategies: 'injectManifest',
// Force output in the prod directory so the symlink works.
outDir: path.resolve(__dirname, 'public/packs'),
manifest: false, manifest: false,
injectRegister: null, injectRegister: null,
injectManifest: { injectManifest: {
@ -128,6 +128,8 @@ const config: UserConfigFnPromise = async ({ mode, command }) => {
MastodonServiceWorkerLocales(), MastodonServiceWorkerLocales(),
], ],
}, },
// Because we move the output dir, we need to scan for assets in the original output directory.
globDirectory: env.VITE_RUBY_PUBLIC_OUTPUT_DIR ?? 'public',
globIgnores: [ globIgnores: [
// Do not preload those files // Do not preload those files
'intl/*.js', 'intl/*.js',