import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; export default defineConfig({ root: __dirname, cacheDir: '../../node_modules/.vite/apps/backoffice', server: { port: 4201, host: 'localhost', }, preview: { port: 4201, host: 'localhost' }, plugins: [react(), nxViteTsPaths()], resolve: { dedupe: ['react', 'react-dom', 'react-router-dom', '@tanstack/react-query'], alias: { // The vendored user-management UI pulls in file-type → token-types, // which imports `node:buffer`. Point it at the browser polyfill so the // production build resolves it instead of failing on a Node built-in. 'node:buffer': 'buffer', }, }, define: { // `buffer` expects a `global` binding that browsers do not provide. global: 'globalThis', }, build: { outDir: '../../dist/apps/backoffice', emptyOutDir: true, reportCompressedSize: true, }, });