从小熊那拷贝一份
This commit is contained in:
38
vite.config.ts
Normal file
38
vite.config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user