Deploy kısımlarında eski uygulamayı günceller
This commit is contained in:
parent
e21c5979b0
commit
ce886ee5e1
1 changed files with 32 additions and 6 deletions
|
|
@ -3,16 +3,18 @@ import react from '@vitejs/plugin-react'
|
|||
import path from 'path'
|
||||
import dynamicImport from 'vite-plugin-dynamic-import'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
import { fetchTenantNames } from './src/services/tenants'
|
||||
// import { fetchTenantNames } from './src/services/tenants'
|
||||
|
||||
export default defineConfig(async ({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
const apiUrl = env.VITE_API_URL
|
||||
const baseDomains = ['sozsoft.com', 'dev.sozsoft.com']
|
||||
const tenantNames = (await fetchTenantNames(apiUrl)).map((n) => n.trim().toLowerCase())
|
||||
const tenantHosts = tenantNames.map((t) => `${t}.sozsoft.com`)
|
||||
const allowedHosts = Array.from(new Set(['localhost', ...baseDomains, ...tenantHosts]))
|
||||
|
||||
// const tenantNames = (await fetchTenantNames(apiUrl)).map((n) => n.trim().toLowerCase())
|
||||
// const tenantHosts = tenantNames.map((t) => `${t}.sozsoft.com`)
|
||||
const tenantHosts: string[] = []
|
||||
|
||||
const allowedHosts = Array.from(new Set(['localhost', ...baseDomains, ...tenantHosts]))
|
||||
console.log('[vite] allowedHosts:', allowedHosts)
|
||||
|
||||
return {
|
||||
|
|
@ -24,11 +26,28 @@ export default defineConfig(async ({ mode }) => {
|
|||
}),
|
||||
dynamicImport(),
|
||||
VitePWA({
|
||||
// Deploy'dan sonra otomatik güncelle
|
||||
registerType: 'autoUpdate',
|
||||
devOptions: { enabled: true },
|
||||
// Kayıt kodunu otomatik enjekte et (virtual:pwa-register yazmadan da çalışır)
|
||||
injectRegister: 'auto',
|
||||
// Dev ortamında SW'yi aç, prod'da kapalı tut (build edilmiş SW prod'da zaten aktif olur)
|
||||
devOptions: { enabled: mode !== 'production' },
|
||||
|
||||
workbox: {
|
||||
// Büyük asset'leri de cache'leyebil
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
|
||||
|
||||
// EN KRİTİK: yeni SW beklemeden kontrolü alsın
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
|
||||
// Eski workbox cache'lerini temizle
|
||||
cleanupOutdatedCaches: true,
|
||||
|
||||
// SPA fallback'i API çağrılarına uygulama
|
||||
navigateFallbackDenylist: [/^\/api\//],
|
||||
},
|
||||
|
||||
manifest: {
|
||||
name: 'Platform',
|
||||
theme_color: '#FF99C8',
|
||||
|
|
@ -45,11 +64,14 @@ export default defineConfig(async ({ mode }) => {
|
|||
},
|
||||
}),
|
||||
],
|
||||
|
||||
server: {
|
||||
open: true,
|
||||
port: 3000,
|
||||
},
|
||||
|
||||
assetsInclude: ['**/*.md'],
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.join(__dirname, 'src'),
|
||||
|
|
@ -57,16 +79,20 @@ export default defineConfig(async ({ mode }) => {
|
|||
'devextreme/ui': 'devextreme/esm/ui',
|
||||
},
|
||||
},
|
||||
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false,
|
||||
},
|
||||
|
||||
preview: {
|
||||
host: '0.0.0.0',
|
||||
port: 80,
|
||||
open: false,
|
||||
allowedHosts: ['localhost', '.sozsoft.com'],
|
||||
// Hesaplanan allowedHosts'u kullan
|
||||
allowedHosts,
|
||||
},
|
||||
|
||||
define: {
|
||||
'process.env': {},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue