小程序开发者工具

配置自动打开小程序开发者工具

devtools 让 unh 在开发小程序时自动打开对应平台的开发者工具。

devtools.open 只对 mp-* 平台生效。目前能自动打开的开发者工具只有微信开发者工具。

配置

unh.config.ts
import { defineConfig } from '@uni-helper/unh'

export default defineConfig({
  devtools: {
    open: true,
  },
})

配置项

devtools.open

open
boolean
是否自动打开小程序开发者工具

devtools.cliPath

cliPath
Record<MPPlatform, CliPathConfig>
开发者工具的 CLI 路径。CliPathConfig 可以是字符串,也可以是平台映射对象。未配置时按平台自动识别。

指定路径

unh.config.ts
import { defineConfig } from '@uni-helper/unh'

export default defineConfig({
  devtools: {
    open: true,
    cliPath: {
      'mp-weixin': '/Applications/wechatwebdevtools.app/Contents/MacOS/cli',
    },
  },
})

注意

  • 必须已安装对应平台的小程序开发者工具。
  • cliPath 必须指向 CLI 工具本身,不是应用目录。
  • 各平台的 CLI 路径不同,必须按实际情况配置。
  • Windows 的路径格式与 macOS 不同,必须使用对应的分隔符。