guoyu/fronted_uniapp/vite.config.js
2025-12-08 19:18:58 +08:00

45 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, '.')
}
},
build: {
// 优化打包性能
minify: 'terser',
terserOptions: {
compress: {
drop_console: false, // 内网环境保留console便于调试
drop_debugger: true
}
},
// 资源内联策略(减少网络请求)
assetsInlineLimit: 10240, // 小于10KB的资源内联为base64
// 分块策略(优化加载速度)
chunkSizeWarningLimit: 1000,
rollupOptions: {
external: ['io.dcloud.uts']
// 注意uniapp环境下vue是外部模块不能手动分块
}
},
server: {
port: 20003,
host: '0.0.0.0',
open: true,
strictPort: false,
proxy: {} // H5环境直接访问后端不使用代理
},
optimizeDeps: {
include: ['uview-plus']
}
})