Files
roa2web-service-auto/reports-app/frontend/vite.config.js
Marius Mutu ee239eb3f3 fix: Resolve shared component styling and Vite module deduplication
- Add dedupe option for vue, vue-router, pinia, primevue in both Vite configs
  to prevent duplicate module issues when using shared components
- Add optimizeDeps and commonjsOptions for better shared module handling
- Fix CompanySelector and PeriodSelector header variants to support both
  light headers (using CSS variables) and gradient headers (white text)
- Make hamburger button always display:flex for consistent mobile layout

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 12:35:14 +02:00

86 lines
2.7 KiB
JavaScript

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
// Plugin pentru a înlocui BUILD_TIMESTAMP în index.html la build
function htmlTimestampPlugin() {
return {
name: 'html-timestamp',
transformIndexHtml(html) {
return html.replace('BUILD_TIMESTAMP', new Date().toISOString())
}
}
}
export default defineConfig({
plugins: [vue(), htmlTimestampPlugin()],
// Base path for production deployment in IIS subdirectory
base: process.env.NODE_ENV === 'production' ? '/roa2web/' : '/',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@shared': fileURLToPath(new URL('../../shared', import.meta.url))
},
dedupe: ['vue', 'vue-router', 'pinia', 'primevue']
},
server: {
port: 3000,
host: true,
// WSL2 file watching fix - use polling for /mnt/ paths
watch: {
usePolling: true, // Required for WSL2 when files are on Windows mount
interval: 1000 // Check for changes every second
},
// HMR configuration for better hot reload
hmr: {
overlay: true, // Show errors in browser overlay
protocol: 'ws', // WebSocket protocol
host: 'localhost' // Explicit host for WSL2
},
proxy: {
'/api': {
target: 'http://localhost:8001',
changeOrigin: true,
secure: false,
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req, res) => {
// Preserve authorization header during redirects
if (req.headers.authorization) {
proxyReq.setHeader('Authorization', req.headers.authorization);
}
});
}
}
}
},
optimizeDeps: {
include: ['vue', 'vue-router', 'pinia']
},
build: {
outDir: 'dist',
sourcemap: true,
commonjsOptions: {
include: [/node_modules/, /shared/]
},
// Cache busting - generează hash-uri noi la fiecare build
assetsInlineLimit: 0, // Nu inline asset-uri mici, folosește fișiere separate cu hash
rollupOptions: {
output: {
// Forțează hash-uri unice pentru toate fișierele
entryFileNames: `assets/[name].[hash].js`,
chunkFileNames: `assets/[name].[hash].js`,
assetFileNames: `assets/[name].[hash].[ext]`,
manualChunks: {
vendor: ['vue', 'vue-router', 'pinia'],
primevue: ['primevue/button', 'primevue/datatable', 'primevue/inputtext'],
utils: ['axios', 'date-fns']
}
}
}
},
// Adaugă timestamp la build pentru versioning
define: {
__APP_VERSION__: JSON.stringify(new Date().toISOString()),
__BUILD_TIMESTAMP__: JSON.stringify(Date.now())
}
})