Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-ts 模板构建的项目,添加 @vitejs/plugin-legacy 插件后无法构建微信小程序 #99

Open
PurpleNoon opened this issue May 27, 2024 · 1 comment

Comments

@PurpleNoon
Copy link

使用 vite-ts 模板构建,添加 @vitejs/plugin-legacy 插件后,无法构建微信小程序(h5 的可以正常构建),由于报错时没有给出详细的错误信息输出,无法确定问题出在哪里
错误信息输出如下:

> [email protected] build:mp-weixin E:\qge\proj\other\uniapp-ts\legacy-test
> uni build -p mp-weixin

正在编译中...

uni-app 有新版本发布,请执行 `npx @dcloudio/uvm@latest` 更新,更新日志详见:https://download1.dcloud.net.cn/hbuilderx/changelog/4.15.2024050802.html
Build failed with errors.
 ELIFECYCLE  Command failed with exit code 1.

项目信息:

  • node 版本:v18.16.0
  • pnpm 版本:v9.1.2

复现项目地址:https://github.com/PurpleNoon/uni-ts-legacy-plugin

完整复现步骤

  1. 使用官网命令拉取 vite-ts 模板并安装依赖
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
cd ./my-vue3-project
pnpm i
  1. 安装 @vitejs/plugin-legacy
pnpm i -D @vitejs/plugin-legacy
  1. vite.config.ts 修改相关代码,并添加 .browserslistrc 文件(没有该文件时同样无法构建)
// vite.config.ts
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
    legacy(),
  ],
});
  1. 执行 pnpm run build:mp-weixin 即可复现
@PurpleNoon
Copy link
Author

补充:
操作系统:Win10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant