Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
57 lines (55 loc) · 2.33 KB
/
Copy pathvite.config.ts
File metadata and controls
57 lines (55 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
// Get port from environment variable with fallback to 5567
const apiPort = process.env.API_PORT || 5567;
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
// Advanced dev only: point `flint-chart` at a local checkout for HMR co-dev.
// FLINT_CHART_LOCAL=../flint-chart/packages/flint-js/src yarn start
// Unset (default) → the bare `flint-chart` import resolves to the installed npm package.
...(process.env.FLINT_CHART_LOCAL
? { 'flint-chart': path.resolve(__dirname, process.env.FLINT_CHART_LOCAL) }
: {}),
},
// Keep a single copy of Flint's (optional) peer deps when aliased to local source.
dedupe: ['vega', 'vega-lite', 'echarts', 'chart.js'],
},
build: {
outDir: path.join(__dirname, 'py-src', 'data_formulator', "dist"),
rollupOptions: {
output: {
entryFileNames: `DataFormulator.js`, // specific name for the main JS bundle
chunkFileNames: `assets/[name]-[hash].js`, // keep default naming for chunks
assetFileNames: `assets/[name]-[hash].[ext]`, // keep default naming for other assets
manualChunks: {
// Separate vendor chunks for better caching and parallel loading
'vendor-react': ['react', 'react-dom', 'react-redux', 'redux', '@reduxjs/toolkit'],
'vendor-mui': ['@mui/material', '@mui/icons-material', '@mui/lab', '@emotion/react', '@emotion/styled'],
'vendor-vega': ['vega', 'vega-lite', 'vega-embed', 'react-vega'],
'vendor-d3': ['d3'],
'vendor-utils': ['lodash', 'localforage', 'dompurify', 'validator'],
'vendor-editor': ['prismjs', 'prism-react-renderer', 'prettier'],
'vendor-markdown': ['markdown-to-jsx', 'katex', 'react-katex'],
'vendor-misc': ['exceljs', 'html2canvas', 'allotment', 'react-dnd', 'react-dnd-html5-backend', 'react-virtuoso'],
}
}
},
chunkSizeWarningLimit: 1000, // Warn if chunks exceed 1MB
},
server: {
proxy: {
'/api': {
target: `http://localhost:${apiPort}`,
changeOrigin: true,
},
'/auth/callback': {
target: `http://localhost:${apiPort}`,
changeOrigin: true,
}
}
}
});