65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import { resolve } from 'path'
|
||
import AutoImport from 'unplugin-auto-import/vite'
|
||
import Components from 'unplugin-vue-components/vite'
|
||
import { VantResolver } from 'unplugin-vue-components/resolvers'
|
||
import VueDevTools from 'vite-plugin-vue-devtools'
|
||
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [
|
||
vue(),
|
||
VueDevTools(),
|
||
AutoImport({
|
||
imports: ['vue', 'vue-router', 'pinia'],
|
||
dts: 'src/auto-imports.d.ts',
|
||
dirs: ['src/composables'], // 只扫描 composables,stores 使用显式导入
|
||
vueTemplate: true
|
||
}),
|
||
Components({
|
||
resolvers: [VantResolver()],
|
||
dts: 'src/components.d.ts'
|
||
})
|
||
],
|
||
resolve: {
|
||
alias: {
|
||
'@': resolve(__dirname, 'src')
|
||
}
|
||
},
|
||
server: {
|
||
port: 3000,
|
||
host: true,
|
||
open: true,
|
||
proxy: {
|
||
'/api': {
|
||
target: 'http://192.168.1.101:9000',
|
||
changeOrigin: true,
|
||
rewrite: (path) => path.replace(/^\/api/, '')
|
||
}
|
||
}
|
||
},
|
||
css: {
|
||
preprocessorOptions: {
|
||
scss: {
|
||
silenceDeprecations: ['legacy-js-api'] // 静默 Sass legacy API 弃用警告
|
||
}
|
||
}
|
||
},
|
||
build: {
|
||
target: 'es2015',
|
||
outDir: 'dist',
|
||
sourcemap: false,
|
||
chunkSizeWarningLimit: 2000,
|
||
rollupOptions: {
|
||
output: {
|
||
manualChunks: {
|
||
vue: ['vue', 'vue-router', 'pinia'],
|
||
vant: ['vant', '@vant/use'],
|
||
artplayer: ['artplayer', 'artplayer-plugin-danmuku']
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|