64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa';
|
|
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const pwaOptions: Partial<VitePWAOptions> = {
|
|
registerType: 'autoUpdate',
|
|
strategies: 'injectManifest', // Crucial for custom service worker
|
|
srcDir: 'src', // Directory where sw.ts is located
|
|
filename: 'sw.ts', // Your custom service worker filename
|
|
devOptions: {
|
|
enabled: true, // Enable PWA in development
|
|
type: 'module',
|
|
},
|
|
manifest: {
|
|
name: 'mitlist',
|
|
short_name: 'mitlist',
|
|
description: 'mitlist pwa',
|
|
theme_color: '#027be3',
|
|
background_color: '#ffffff',
|
|
display: 'standalone',
|
|
orientation: 'portrait',
|
|
icons: [
|
|
{ src: 'icons/icon-128x128.png', sizes: '128x128', type: 'image/png' },
|
|
{ src: 'icons/icon-192x192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: 'icons/icon-256x256.png', sizes: '256x256', type: 'image/png' },
|
|
{ src: 'icons/icon-384x384.png', sizes: '384x384', type: 'image/png' },
|
|
{ src: 'icons/icon-512x512.png', sizes: '512x512', type: 'image/png' },
|
|
],
|
|
},
|
|
injectManifest: {
|
|
// Options for workbox.injectManifest
|
|
// Ensure your custom service worker (sw.ts) correctly handles __WB_MANIFEST
|
|
},
|
|
};
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
VitePWA(pwaOptions),
|
|
VueI18nPlugin({
|
|
include: [path.resolve(path.dirname(fileURLToPath(import.meta.url)), './src/i18n/**')],
|
|
strictMessage: false, // To avoid warnings for missing Quasar translations initially
|
|
runtimeOnly: false, // If you use <i18n> component or complex messages
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
// Define env variables similar to Quasar's process.env
|
|
define: {
|
|
'process.env.PWA_FALLBACK_HTML': JSON.stringify('/index.html'), // Adjust if you have a specific offline.html
|
|
'process.env.PWA_SERVICE_WORKER_REGEX': JSON.stringify(/^(sw|workbox)-.*\.js$/),
|
|
'process.env.MODE': JSON.stringify(process.env.NODE_ENV),
|
|
'process.env.PROD': JSON.stringify(process.env.NODE_ENV === 'production'),
|
|
},
|
|
server: {
|
|
open: true,
|
|
},
|
|
}); |