|
|
@@ -1,8 +1,7 @@
|
|
|
-import path from 'node:path'
|
|
|
-import { execSync } from 'node:child_process'
|
|
|
+import Uni from '@dcloudio/vite-plugin-uni'
|
|
|
import dayjs from 'dayjs'
|
|
|
+import path from 'node:path'
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
-import Uni from '@dcloudio/vite-plugin-uni'
|
|
|
// @see https://uni-helper.js.org/vite-plugin-uni-pages
|
|
|
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
|
|
// @see https://uni-helper.js.org/vite-plugin-uni-layouts
|
|
|
@@ -13,9 +12,9 @@ import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
|
|
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
|
|
import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
|
|
// @see https://unocss.dev/
|
|
|
+import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
import UnoCSS from 'unocss/vite'
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
-import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
import ViteRestart from 'vite-plugin-restart'
|
|
|
import { copyNativeRes } from './vite-plugins/copyNativeRes'
|
|
|
|
|
|
@@ -98,13 +97,13 @@ export default ({ command, mode }) => {
|
|
|
},
|
|
|
// 打包分析插件,h5 + 生产环境才弹出
|
|
|
UNI_PLATFORM === 'h5' &&
|
|
|
- mode === 'production' &&
|
|
|
- visualizer({
|
|
|
- filename: './node_modules/.cache/visualizer/stats.html',
|
|
|
- open: true,
|
|
|
- gzipSize: true,
|
|
|
- brotliSize: true,
|
|
|
- }),
|
|
|
+ mode === 'production' &&
|
|
|
+ visualizer({
|
|
|
+ filename: './node_modules/.cache/visualizer/stats.html',
|
|
|
+ open: true,
|
|
|
+ gzipSize: true,
|
|
|
+ brotliSize: true,
|
|
|
+ }),
|
|
|
// 只有在 app 平台时才启用 copyNativeRes 插件
|
|
|
UNI_PLATFORM === 'app' && copyNativeRes(),
|
|
|
],
|
|
|
@@ -136,12 +135,12 @@ export default ({ command, mode }) => {
|
|
|
// 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
|
|
|
proxy: JSON.parse(VITE_APP_PROXY)
|
|
|
? {
|
|
|
- [VITE_APP_PROXY_PREFIX]: {
|
|
|
- target: VITE_SERVER_BASEURL,
|
|
|
- changeOrigin: true,
|
|
|
- rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
|
|
- },
|
|
|
- }
|
|
|
+ [VITE_APP_PROXY_PREFIX]: {
|
|
|
+ target: VITE_SERVER_BASEURL,
|
|
|
+ changeOrigin: true,
|
|
|
+ rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
|
|
+ },
|
|
|
+ }
|
|
|
: undefined,
|
|
|
},
|
|
|
build: {
|