diff --git a/build/proxy.ts b/build/proxy.ts index 315f809..7c5f31c 100644 --- a/build/proxy.ts +++ b/build/proxy.ts @@ -1,3 +1,5 @@ +import type { ProxyOptions } from 'vite'; + /** * Configure according to the proxy list * @param proxyList diff --git a/build/vitePlugins.ts b/build/vitePlugins.ts index b3b8877..69a99fc 100644 --- a/build/vitePlugins.ts +++ b/build/vitePlugins.ts @@ -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, diff --git a/package.json b/package.json index fcdf355..a3ac90f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/vite.config.ts b/vite.config.ts index 240169e..4636d7e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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: {