26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { defineConfig, type Plugin } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const buildId = `${Date.now()}`
|
|
const versionAsset = ():Plugin => ({
|
|
name: 'codexpi-version-asset',
|
|
generateBundle(){this.emitFile({type:'asset',fileName:'version.json',source:JSON.stringify({build:buildId})})},
|
|
})
|
|
|
|
export default defineConfig({
|
|
define: {'__CODEXPI_BUILD_ID__': JSON.stringify(buildId)},
|
|
plugins: [react(),versionAsset()],
|
|
server: { host: '127.0.0.1', port: 5173, proxy: { '/api': 'http://127.0.0.1:8765', '/ws': { target: 'ws://127.0.0.1:8765', ws: true } } },
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (['react-markdown', 'remark-gfm', 'rehype-highlight', 'highlight.js'].some(name => id.includes(`/node_modules/${name}/`))) return 'markdown'
|
|
if (['@xterm/xterm', '@xterm/addon-fit'].some(name => id.includes(`/node_modules/${name}/`))) return 'terminal'
|
|
if (['react', 'react-dom'].some(name => id.includes(`/node_modules/${name}/`))) return 'react'
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|