| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import { viteSingleFile } from 'vite-plugin-singlefile'
- import fs from 'fs'
- // 数据路径由 Python 通过环境变量传入
- const dataPath = process.env.GRAPH_DATA_PATH
- if (!dataPath) {
- console.error('错误: 请设置 GRAPH_DATA_PATH 环境变量')
- process.exit(1)
- }
- console.log('数据文件:', dataPath)
- // 读取 JSON 数据
- const graphData = JSON.parse(fs.readFileSync(dataPath, 'utf-8'))
- console.log('节点数:', Object.keys(graphData.nodes || {}).length)
- console.log('边数:', (graphData.edges || []).length)
- export default defineConfig({
- plugins: [vue(), viteSingleFile()],
- define: {
- // 将数据注入为全局常量
- __GRAPH_DATA__: JSON.stringify(graphData)
- },
- build: {
- target: 'esnext',
- outDir: 'dist',
- assetsInlineLimit: 100000000,
- chunkSizeWarningLimit: 100000000,
- cssCodeSplit: false,
- rollupOptions: {
- output: {
- inlineDynamicImports: true
- }
- }
- }
- })
|