2025-08-12 08:39:06 +00:00
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
2025-05-06 06:45:49 +00:00
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
|
import path from 'path'
|
|
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// import { fetchTenantNames } from './src/services/tenants'
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
2025-08-12 08:39:06 +00:00
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
|
|
|
|
const apiUrl = env.VITE_API_URL
|
2025-08-14 08:49:22 +00:00
|
|
|
|
const baseDomains = ['sozsoft.com', 'dev.sozsoft.com', '.sozsoft.com']
|
2025-08-12 12:53:51 +00:00
|
|
|
|
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// 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]))
|
2025-08-16 12:22:36 +00:00
|
|
|
|
console.log('> [vite] allowedHosts:', allowedHosts)
|
2025-08-12 12:53:51 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
return {
|
|
|
|
|
|
plugins: [
|
2025-08-16 12:22:36 +00:00
|
|
|
|
react(),
|
2025-08-11 22:08:28 +00:00
|
|
|
|
VitePWA({
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// Deploy'dan sonra otomatik güncelle
|
2025-08-11 22:08:28 +00:00
|
|
|
|
registerType: 'autoUpdate',
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// 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' },
|
|
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
workbox: {
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// Büyük asset'leri de cache'leyebil
|
2025-08-11 22:08:28 +00:00
|
|
|
|
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
|
|
|
|
|
// 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\//],
|
2025-08-11 22:08:28 +00:00
|
|
|
|
},
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
manifest: {
|
|
|
|
|
|
name: 'Platform',
|
|
|
|
|
|
theme_color: '#FF99C8',
|
|
|
|
|
|
background_color: '#f0e7db',
|
|
|
|
|
|
display: 'standalone',
|
|
|
|
|
|
icons: [
|
|
|
|
|
|
{
|
|
|
|
|
|
src: '/img/logo/logo-400.png',
|
|
|
|
|
|
sizes: '400x400',
|
|
|
|
|
|
type: 'image/png',
|
|
|
|
|
|
purpose: 'any',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
server: {
|
|
|
|
|
|
open: true,
|
|
|
|
|
|
port: 3000,
|
|
|
|
|
|
},
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
assetsInclude: ['**/*.md'],
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
resolve: {
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
'@': path.join(__dirname, 'src'),
|
|
|
|
|
|
inferno: 'inferno/dist/index.esm.js',
|
|
|
|
|
|
'devextreme/ui': 'devextreme/esm/ui',
|
2025-05-06 06:45:49 +00:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
build: {
|
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
|
sourcemap: false,
|
2025-08-18 14:55:51 +00:00
|
|
|
|
rollupOptions: {
|
|
|
|
|
|
output: {
|
|
|
|
|
|
manualChunks(id) {
|
|
|
|
|
|
if (id.includes('node_modules')) {
|
|
|
|
|
|
if (id.match(/node_modules[\\/]react/)) return 'vendor-react'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]react-dom/)) return 'vendor-reactdom'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]devextreme/)) return 'vendor-devextreme'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]@devexpress/)) return 'vendor-devexpress'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]devextreme-react/)) return 'vendor-devextreme-react'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]axios/)) return 'vendor-axios'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]formik/)) return 'vendor-formik'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]jspdf/)) return 'vendor-jspdf'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]exceljs/)) return 'vendor-exceljs'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]html2canvas/)) return 'vendor-html2canvas'
|
|
|
|
|
|
if (id.match(/node_modules[\\/]@?react-router/)) return 'vendor-reactrouter'
|
|
|
|
|
|
// Büyük modüller için özel chunk
|
|
|
|
|
|
if (id.match(/src[\\/]codeParser/)) return 'chunk-codeParser'
|
|
|
|
|
|
if (id.match(/src[\\/]views[\\/]list[\\/]Utils/)) return 'chunk-list-utils'
|
|
|
|
|
|
return 'vendor'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-08-11 22:08:28 +00:00
|
|
|
|
},
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
preview: {
|
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
|
port: 80,
|
|
|
|
|
|
open: false,
|
2025-08-13 20:42:18 +00:00
|
|
|
|
// Hesaplanan allowedHosts'u kullan
|
|
|
|
|
|
allowedHosts,
|
2025-08-11 22:08:28 +00:00
|
|
|
|
},
|
2025-08-13 20:42:18 +00:00
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
|
define: {
|
|
|
|
|
|
'process.env': {},
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
2025-05-06 06:45:49 +00:00
|
|
|
|
})
|