| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { defineConfig } from 'vite'
- import uni from '@dcloudio/vite-plugin-uni'
- import path from 'path'
- // https://vitejs.dev/config/
- export default defineConfig(({ command, mode }) => {
- const isApp = process.env.UNI_PLATFORM === 'app' || process.env.UNI_PLATFORM === 'app-harmony'
-
- return {
- plugins: [uni()],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './'),
- // 添加 uview-plus 别名
- 'uview-plus': path.resolve(__dirname, './node_modules/uview-plus')
- }
- },
- css: {
- preprocessorOptions: {
- scss: {
- // 可以在这里添加全局 scss 变量
- // 取消sass废弃API的报警
- silenceDeprecations: ['legacy-js-api', 'color-functions', 'import'],
- }
- }
- },
- server: {
- proxy: {
- // H5 开发环境代理配置
- '/base': {
- // target: 'http://localhost:8080',
- target:'https://azn.gbdfarm.com/prod-api',
- changeOrigin: true,
- secure: false,
- rewrite: (path) => path.replace(/^\/base/, ''),
- },
- // WVP 视频平台代理配置
- '/wvp': {
- target: 'https://nxy.gbdfarm.com:9000',
- changeOrigin: true,
- secure: false,
- rewrite: (path) => path.replace(/^\/wvp/, '/wvp'),
- },
- },
- },
- build: {
- // 生产环境移除 console
- minify: 'terser',
- terserOptions: {
- compress: {
- drop_console: true,
- drop_debugger: true
- }
- },
- // App 平台(包括鸿蒙)禁用代码分割,避免 iife 格式错误
- rollupOptions: isApp ? {
- output: {
- format: 'es',
- inlineDynamicImports: true, // 关键:禁用代码分割
- manualChunks: undefined
- }
- } : {
- output: {
- format: 'es',
- manualChunks: undefined
- }
- },
- target: 'esnext'
- }
- }})
|