54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
const appVersion = process.env.npm_package_version ?? '0.0.0'
|
|
const appCommit = (
|
|
process.env.GITEA_SHA ??
|
|
process.env.GITHUB_SHA ??
|
|
process.env.COMMIT_SHA ??
|
|
'dev'
|
|
).slice(0, 12)
|
|
const appBuiltAt = new Date().toISOString()
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(appVersion),
|
|
__APP_COMMIT__: JSON.stringify(appCommit),
|
|
__APP_BUILT_AT__: JSON.stringify(appBuiltAt),
|
|
},
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
VitePWA({
|
|
registerType: 'prompt',
|
|
manifest: false, // manifest.json from public
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,json}'],
|
|
cleanupOutdatedCaches: true,
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: /^https:\/\/.*\/api\//,
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'api-cache',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
allowedHosts: ['delivery.loca.lt', '.loca.lt'],
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
})
|