import { fileURLToPath, URL } from 'node:url'; import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; // Ported from legacy henza_admin/vue.config.js. // The legacy build switched publicPath/outputDir on NODE_ENV=='branch'; in Vite the // equivalent switch is the --mode flag (`pnpm dev:branch` / `pnpm build:branch`), // which src/utils/index.ts reads via import.meta.env.MODE. export default defineConfig(({ mode }) => { const isBranch = mode === 'branch'; return { // legacy: publicPath: isBranch ? '/branch/' : 'admin/' base: isBranch ? '/branch/' : '/admin/', plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, css: { preprocessorOptions: { less: { // ant-design-vue 4 dropped LESS theming (modifyVars) for CSS-in-JS design // tokens; the equivalent primary/link/radius tokens now live in // App.vue's . This block only compiles the // app's own farsi.less/utilities.less, which have no LESS variables. javascriptEnabled: true, }, }, }, build: { // Legacy's vue.config.js used outputDir 'dist/export' / 'branchDist/export', // but this app's Dockerfile does `COPY dist /usr/share/nginx/html` and nginx // serves that folder's ROOT. With the build landing in dist/export/, the // root kept whatever index.html was committed there before — a stale // pre-port build — so the deployed panel served that instead of this app. // Build straight into the folder the image actually serves (which is also // what apps/user-app does). outDir: isBranch ? 'branchDist' : 'dist', emptyOutDir: true, sourcemap: false, // legacy: productionSourceMap: false }, server: { port: 5174, proxy: { '/api': 'http://localhost:3000', }, }, }; });