- pnpm-workspace.yaml 增加 packages 字段,修复 pnpm 9 的 packages field missing or empty 报错 - 新增 index.html,访问根路径自动跳转到 list.html 排行榜页 - vite.config.ts 构建入口加入 index.html - .gitignore 忽略 .idea,并从暂存区移除已跟踪的 .idea 文件
40 lines
1006 B
TypeScript
40 lines
1006 B
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import { resolve } from 'node:path'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const target = env.SUB2API_BASE_URL || 'https://sub2api.example.com'
|
|
const adminKey = env.ADMIN_API_KEY || env.VITE_ADMIN_API_KEY || ''
|
|
|
|
return {
|
|
plugins: [vue()],
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
index: resolve(__dirname, 'index.html'),
|
|
list: resolve(__dirname, 'list.html'),
|
|
groups: resolve(__dirname, 'groups.html'),
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
host: true,
|
|
port: 5176,
|
|
strictPort: true,
|
|
proxy: {
|
|
'/api': {
|
|
target,
|
|
changeOrigin: true,
|
|
secure: true,
|
|
configure(proxy) {
|
|
proxy.on('proxyReq', (proxyReq) => {
|
|
if (adminKey) proxyReq.setHeader('x-api-key', adminKey)
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|