import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' // https://vite.dev/config/ export default defineConfig(({ mode }) => { // VITE_BASE_PATH is read here (config/Node context), so it needs an explicit // loadEnv call โ€” unlike VITE_BITRIX_ORIGIN, which Vite injects into // import.meta.env automatically because it's only read from app code. const env = loadEnv(mode, process.cwd(), '') return { // Needed when the build is served from a subpath (e.g. local/diagram-app/ // inside the Bitrix docroot) instead of domain root โ€” see // docs/bitrix-integration.md ยง7. base: env.VITE_BASE_PATH || '/', plugins: [react()], build: { // No content hashes in output filenames โ€” cache-busting on redeploy is // handled at the hosting/nginx level instead (see docs/bitrix-integration.md). // Flat layout (no "assets/" subfolder): one deployment target's own // folder is literally named "assets" (local/modules/vniigaz.bpmn/assets/), // and nesting output under another "assets/" there doubled the path // segment (.../assets/assets/index.js, 404). Flat works everywhere. rolldownOptions: { output: { entryFileNames: '[name].js', chunkFileNames: '[name].js', assetFileNames: '[name].[ext]', }, }, }, } })