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 dynamicImport from 'vite-plugin-dynamic-import'
|
|
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2025-08-12 08:39:06 +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-12 12:53:51 +00:00
|
|
|
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`)
|
2025-08-11 22:08:28 +00:00
|
|
|
const allowedHosts = Array.from(new Set(['localhost', ...baseDomains, ...tenantHosts]))
|
2025-08-12 12:53:51 +00:00
|
|
|
|
|
|
|
|
console.log('[vite] allowedHosts:', allowedHosts)
|
|
|
|
|
|
2025-08-11 22:08:28 +00:00
|
|
|
return {
|
|
|
|
|
plugins: [
|
|
|
|
|
react({
|
|
|
|
|
babel: {
|
|
|
|
|
plugins: ['babel-plugin-macros', '@babel/plugin-syntax-dynamic-import'],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
dynamicImport(),
|
|
|
|
|
VitePWA({
|
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
|
devOptions: { enabled: true },
|
|
|
|
|
workbox: {
|
|
|
|
|
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
|
|
|
|
|
},
|
|
|
|
|
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',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
server: {
|
|
|
|
|
open: true,
|
|
|
|
|
port: 3000,
|
|
|
|
|
},
|
|
|
|
|
assetsInclude: ['**/*.md'],
|
|
|
|
|
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-11 22:08:28 +00:00
|
|
|
build: {
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
},
|
|
|
|
|
preview: {
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
port: 80,
|
|
|
|
|
open: false,
|
2025-08-12 14:19:38 +00:00
|
|
|
allowedHosts: ['localhost', '.sozsoft.com'],
|
2025-08-11 22:08:28 +00:00
|
|
|
},
|
|
|
|
|
define: {
|
|
|
|
|
'process.env': {},
|
|
|
|
|
},
|
|
|
|
|
}
|
2025-05-06 06:45:49 +00:00
|
|
|
})
|