fix(build): 修复pnpm构建出错的问题

This commit is contained in:
h_mo 2024-09-07 23:52:28 +08:00
parent 8255dd72b2
commit a0b559f7d2
4 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import type { ProxyOptions } from 'vite';
/**
* Configure according to the proxy list
* @param proxyList

View File

@ -4,6 +4,7 @@ import { UnifiedViteWeappTailwindcssPlugin as uvtw } from 'weapp-tailwindcss/vit
import autoImport from 'unplugin-auto-import/vite';
import viteRestart from 'vite-plugin-restart';
import { visualizer } from 'rollup-plugin-visualizer';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { WeappTailwindcssDisabled, isH5 } from './platform';
interface VitePluginConfig {
@ -14,6 +15,7 @@ export function createVitePlugins({ isProd }: VitePluginConfig): PluginOption[]
return [
// @ts-expect-error TODO uni() 会报错uni is not a function,暂时使用此方式解决
uni?.default(),
nodeResolve(),
uvtw({
rem2rpx: true,
disabled: WeappTailwindcssDisabled,

View File

@ -74,6 +74,7 @@
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4020720240905001",
"@egoist/tailwindcss-icons": "^1.8.1",
"@iconify/json": "^2.2.245",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.16.5",

View File

@ -48,7 +48,7 @@ export default defineConfig(async ({ mode }) => {
host: true,
// open: true,
port: Number.parseInt(VITE_PORT!, 10),
proxy: resolveProxy([[VITE_PROXY_PREFIX, VITE_BASE_URL], [VITE_UPLOAD_PROXY_PREFIX, VITE_UPLOAD_URL]]),
proxy: resolveProxy([[VITE_PROXY_PREFIX!, VITE_BASE_URL!], [VITE_UPLOAD_PROXY_PREFIX!, VITE_UPLOAD_URL!]]),
},
// 构建配置
build: {