| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import vueDevTools from 'vite-plugin-vue-devtools'
- import { resolve } from 'path'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
- import pkg from './package.json'
- export default defineConfig({
- plugins: [
- process.env.NODE_ENV === 'development' && vueDevTools(),
- vue(),
- AutoImport({
- imports: ['vue', 'vue-router', 'pinia'],
- resolvers: [ElementPlusResolver()],
- dts: 'src/auto-imports.d.ts',
- eslintrc: {
- enabled: true,
- filepath: './.eslintrc-auto-import.json',
- globalsPropValue: true
- }
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- dts: 'src/components.d.ts'
- })
- ],
- define: {
- __APP_VERSION__: JSON.stringify(pkg.version)
- },
- resolve: {
- alias: {
- '@': resolve(__dirname, 'src')
- }
- },
- server: {
- host: '0.0.0.0',
- port: 3000,
- open: true,
- proxy: {
- // 后端 API
- '/api': {
- target: 'https://tg-live-game.pwtk.cc',
- changeOrigin: true,
- secure: false // 禁用 SSL 证书验证(开发环境)
- }
- }
- },
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: `@use "@/assets/styles/variables.scss" as *;`,
- silenceDeprecations: ['legacy-js-api']
- }
- }
- },
- build: {
- chunkSizeWarningLimit: 1500,
- rollupOptions: {
- output: {
- manualChunks(id) {
- if (id.includes('node_modules')) {
- // Vue 核心和 Element Plus 放在一起,避免循环依赖
- if (
- id.includes('vue') ||
- id.includes('@vue') ||
- id.includes('element-plus') ||
- id.includes('@element-plus') ||
- id.includes('pinia') ||
- id.includes('vue-router')
- ) {
- return 'vendor'
- }
- }
- }
- }
- }
- }
- })
|