vite-plugin-open-wechat-devtools
v1.0.1
Published
Vite plugin to automatically open WeChat DevTools after dev/build
Maintainers
Readme
vite-plugin-open-wechat-devtools
Vite 插件,在 dev 或 build 完成后自动打开微信开发者工具。专为 uni-app 微信小程序开发设计。
安装
npm install vite-plugin-open-wechat-devtools -D使用
// vite.config.ts
import { defineConfig } from 'vite'
import openWechatDevtools from 'vite-plugin-open-wechat-devtools'
export default defineConfig({
plugins: [
openWechatDevtools({
// 可选配置项
projectName: '我的小程序',
}),
],
})配置项
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| devToolsPath | string | 自动检测 | 微信开发者工具 CLI 路径 |
| projectPath | string | dist/dev/mp-weixin (dev) / dist/build/mp-weixin (build) | 小程序项目输出目录(相对于项目根目录) |
| projectName | string | - | 项目名称,写入 project.config.json 的 projectname 字段 |
插件会通过 process.argv 自动检测当前运行的是 dev 还是 build 命令,并据此选择正确的输出目录(dist/dev/mp-weixin 或 dist/build/mp-weixin)。
默认 CLI 路径
插件会自动检测以下默认安装路径:
- macOS:
/Applications/wechatwebdevtools.app/Contents/MacOS/cli - Windows:
C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat
如果安装在非默认路径,请通过 devToolsPath 手动指定。
前提条件
- 已安装 微信开发者工具
- 在开发者工具中开启 设置 → 安全设置 → 服务端口
License
MIT
