@cloudbase/framework-plugin-mp
TypeScript icon, indicating that this package has built-in type declarations

1.9.7 • Public • Published

Tencent CloudBase Framework MP Plugin

Tencent CloudBase Framework MiniProgram Plugin

Github License Npm version issue PRs Welcome star

云开发 CloudBase Framework 框架「小程序」插件: 通过云开发 CloudBase Framework 框架一键部署微信小程序应用。

功能特性

使用方法

步骤一. 准备工作

具体步骤请参照 准备云开发环境和 CloudBase CLI 命令工具

步骤二. 进入项目目录进行初始化

如果是目前已有的小程序应用项目

cloudbase

步骤三. 一键部署

cloudbase framework deploy

配置

默认情况下仅需要配置 appidprivateKeyPath 即可使用,以下配置参数针对有特殊需求的场景

配置示例

cloudbase init 之后会创建云开发的配置文件 cloudbaserc.json,可在配置文件的 plugins 里修改和写入插件配置

{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKeyPath": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "preview",
          "previewOptions": {
            "desc": "CloudBase Framework 一键预览",
            "setting": {
              "es6": true
            },
            "qrcodeOutputPath": "./qrcode.jpg",
            "pagePath": "pages/index/index"
          }
        }
      }
    }
  }
}

默认模板的 appidprivateKeyPath 为空,需要开发者填入

配置参数说明

appid

必填,小程序应用的 appid

privateKey

选填,小程序应用的部署私钥内容,需要经过 base64 编码

可以使用 小程序部署密钥转换小工具 来转换为 Base64

privateKeyPath

选填,小程序应用的部署私钥的本地相对路径,默认值 "./private.key"

commands

选填,对象格式

自定义命令,声明应用安装/构建的自定义命令,会在当前项目目录下进行执行

commands.install

安装命令,如npm install,没有可不传

默认会在小程序目录执行 npm install --prefer-offline --no-audit --progress=false

commands.build

构建命令,如npm run build,没有可不传

localPath

选填,小程序项目 project.config.json 所在的本地路径,默认值 ./

ignores

选填,小程序应用部署时忽略的文件路径,支持通配符,默认值["node_modules/**/*"]

deployMode

选填,小程序应用的部署模式,支持 preview|upload 2 种部署模式

previewOptions

deployMode 填写为 preview 时需要填写previewOptions,类型是对象格式

属性名称 类型 是否必填 描述
desc String 小程序应用的版本描述
setting IMiniProgramBuildSetting 对象 小程序应用的编译设置
qrcodeOutputPath String 生成的预览二维码保存在本地的路径
pagePath String 小程序应用的预览页面地址
searchQuery String 小程序应用的预览页面参数
scene Number 小程序应用的预览页面场景值

例如

{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKey": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "preview",
          "previewOptions": {
            "desc": "一键预览",
            "setting": {
              "es6": false
            },
            "qrcodeOutputPath": "./qrcode.jpg",
            "pagePath": "pages/index/index",
            "searchQuery": "",
            "scene": 1011
          }
        }
      }
    }
  }
}

uploadOptions

deployMode 填写为 upload 时需要填写uploadOptions,类型是对象格式

属性名称 类型 是否必填 描述
version String 对象 小程序应用上传的版本号
desc String 对象 小程序应用的版本描述
setting IMiniProgramBuildSetting 对象 小程序应用的编译设置

例如

{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKey": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "upload",
          "uploadOptions": {
            "version": "1.0.0",
            "desc": "CloudBase Framework 一键上传",
            "setting": {
              "es6": false
            }
          }
        }
      }
    }
  }
}

更多插件

请访问 CloudBase Framework 插件列表 搭配使用其他插件

文档资料

Readme

Keywords

none

Package Sidebar

Install

npm i @cloudbase/framework-plugin-mp

Weekly Downloads

2

Version

1.9.7

License

Apache-2.0

Unpacked Size

40.7 kB

Total Files

6

Last publish

Collaborators

  • yuzhen
  • woodenstone
  • justan
  • miusuncle
  • wangjiachen
  • wedabot
  • barretyi
  • daniel-dx
  • issacliu
  • liuyanjie
  • bobbyzhao
  • starkwang
  • yhyang
  • binggg
  • fengkx