guoyu/fronted_uniapp/vite.config.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-12-03 18:58:36 +08:00
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
export default defineConfig({
plugins: [uni()],
resolve: {
alias: {
'@': path.resolve(__dirname, '.')
}
},
2025-12-07 00:11:06 +08:00
build: {
// 优化打包性能
minify: 'terser',
terserOptions: {
compress: {
drop_console: false, // 内网环境保留console便于调试
drop_debugger: true
}
},
// 资源内联策略(减少网络请求)
assetsInlineLimit: 10240, // 小于10KB的资源内联为base64
// 分块策略(优化加载速度)
chunkSizeWarningLimit: 1000,
2025-12-07 00:11:06 +08:00
rollupOptions: {
external: ['io.dcloud.uts']
// 注意uniapp环境下vue是外部模块不能手动分块
2025-12-07 00:11:06 +08:00
}
},
2025-12-03 18:58:36 +08:00
server: {
port: 20003,
host: '0.0.0.0',
open: true,
strictPort: false,
proxy: {
'/api': {
target: 'http://192.168.0.106:30091',
2025-12-03 18:58:36 +08:00
changeOrigin: true,
secure: false
},
// 代理 WebSocket 连接
'/ws': {
target: 'http://192.168.0.106:30091',
2025-12-03 18:58:36 +08:00
ws: true,
changeOrigin: true,
secure: false
}
}
},
optimizeDeps: {
include: ['uview-plus']
}
})