45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
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']
|
||
}
|
||
})
|
||
|