68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
const isDev = mode === 'development'
|
|
|
|
const apiTarget = env.VITE_DEV_API_TARGET || 'https://gateway.oegame.com/shixin'
|
|
const apiProxyCommon = {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
secure: apiTarget.startsWith('https'),
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
timeout: 120000,
|
|
proxyTimeout: 120000,
|
|
}
|
|
|
|
return {
|
|
plugins: [vue()],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'/@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 3001,
|
|
open: true,
|
|
proxy: {
|
|
'/api': apiProxyCommon,
|
|
},
|
|
},
|
|
base: '/',
|
|
esbuild: {
|
|
drop: isDev ? [] : ['console', 'debugger'],
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'assets',
|
|
sourcemap: isDev,
|
|
chunkSizeWarningLimit: 2000,
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: 'assets/[name]-[hash].js',
|
|
chunkFileNames: 'assets/[name]-[hash].js',
|
|
assetFileNames: 'assets/[name]-[hash].[ext]',
|
|
manualChunks: {
|
|
'vendor-vue': ['vue', 'vue-router', 'pinia'],
|
|
'vendor-element': ['element-plus'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: '',
|
|
},
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
include: ['vue', 'vue-router', 'pinia'],
|
|
},
|
|
}
|
|
})
|