Commit non-media application and asset changes while leaving audio, video, and environment files out of version control. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
base: './',
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
// port: 5000,
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: 'js/[name]-[hash].js',
|
|
chunkFileNames: 'js/[name]-[hash].js',
|
|
assetFileNames: (assetInfo) => {
|
|
const filename = assetInfo.names[0] ?? assetInfo.originalFileNames[0] ?? ''
|
|
const ext = path.extname(filename).slice(1).toLowerCase()
|
|
|
|
if (ext === 'css') return 'css/[name]-[hash][extname]'
|
|
if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'avif'].includes(ext)) {
|
|
return 'images/[name]-[hash][extname]'
|
|
}
|
|
|
|
return 'assets/[name]-[hash][extname]'
|
|
},
|
|
manualChunks: (id) => {
|
|
// 将 components/index.ts 和它导出的组件放在同一个 chunk,避免循环依赖
|
|
if (
|
|
id.includes('components/index') ||
|
|
id.includes('components/guide/StudyGuideModal') ||
|
|
id.includes('components/clue/ClueHintModal') ||
|
|
id.includes('components/clue/ClueBookModal')
|
|
) {
|
|
return 'components-shared'
|
|
}
|
|
// 将其他 guide 和 clue 组件也放在同一个 chunk
|
|
if (id.includes('components/guide') || id.includes('components/clue')) {
|
|
return 'components-shared'
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|