You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
|
3 weeks ago
|
import { defineConfig, loadEnv } from 'vite'
|
||
|
|
import vue from '@vitejs/plugin-vue'
|
||
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
||
|
|
import Components from 'unplugin-vue-components/vite'
|
||
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||
|
|
import { resolve } from 'path'
|
||
|
|
|
||
|
|
// https://vite.dev/config/
|
||
|
|
export default defineConfig(({ mode }) => {
|
||
|
|
const env = loadEnv(mode, process.cwd(), '')
|
||
|
|
|
||
|
|
return {
|
||
|
|
plugins: [
|
||
|
|
vue(),
|
||
|
|
AutoImport({
|
||
|
|
imports: ['vue', 'vue-router', 'pinia'],
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
dts: 'src/auto-imports.d.ts',
|
||
|
|
}),
|
||
|
|
Components({
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
dts: 'src/components.d.ts',
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': resolve(__dirname, 'src'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 80,
|
||
|
|
host: true,
|
||
|
|
proxy: {
|
||
|
|
'/dev-api': {
|
||
|
|
target: env.VITE_API_URL || 'http://localhost:8080',
|
||
|
|
changeOrigin: true,
|
||
|
|
rewrite: (path) => path.replace(/^\/dev-api/, ''),
|
||
|
|
},
|
||
|
|
'/prod-api': {
|
||
|
|
target: env.VITE_API_URL || 'http://localhost:8080',
|
||
|
|
changeOrigin: true,
|
||
|
|
rewrite: (path) => path.replace(/^\/prod-api/, ''),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
target: 'es2015',
|
||
|
|
outDir: 'dist',
|
||
|
|
assetsDir: 'assets',
|
||
|
|
sourcemap: false,
|
||
|
|
chunkSizeWarningLimit: 1500,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
manualChunks: {
|
||
|
|
'element-plus': ['element-plus'],
|
||
|
|
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
||
|
|
'echarts': ['echarts', 'vue-echarts'],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
})
|