39 lines
955 B
TypeScript
39 lines
955 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: {
|
|
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)
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|