WeChat Mini Program Plugin
Tencent CloudBase Framework MiniProgram Plugin
**CloudBase Framework 'Mini Program' Plugin**: Deploy WeChat Mini Program applications with one click via the **[CloudBase Framework](https://github.com/Tencent/cloudbase-framework)**.Features
Usage
Step 1. Preparations
Specific steps please refer to Preparing the Cloud Development Environment and CloudBase CLI Command Tool
Step 2. Enter the project directory and initialize
If it is an existing Mini Program application project
cloudbase
Step 3. One-Click Deployment
cloudbase framework deploy
Configuration
By default, only appid
and privateKeyPath
need to be configured for use. The following configuration parameters are for scenarios with specific requirements.
Configuration Example
After running
cloudbase init, the Cloud Development configuration file
cloudbaserc.json` will be created. You can modify and write plugin configurations in the plugins section of the configuration file.
{
"envId": "{{envId}}",
"framework": {
"plugins": {
"client": {
"use": "@cloudbase/framework-plugin-mp",
"inputs": {
"appid": "",
"privateKeyPath": "",
"localPath": "./",
"ignores": ["node_modules/**/*"],
"deployMode": "preview",
"previewOptions": {
"desc": "CloudBase Framework one-click preview",
"setting": {
"es6": true
},
"qrcodeOutputPath": "./qrcode.jpg",
"pagePath": "pages/index/index"
}
}
}
}
}
}
> The appid
and privateKeyPath
in the default template are empty and need to be filled in by the developer
Configuration Parameters Description
appid
Required, the appid of the Mini Program
privateKey
Optional. The deployment private key content for the Mini Program must be base64 encoded.
You can use the Mini Program Deployment Key Conversion Tool to convert to Base64
privateKeyPath
Optional. The local relative path of the deployment private key for the Mini Program, default "./private.key"
commands
Optional. Object format.
Custom commands define the application installation/build commands, which are executed in the current project directory.
commands.install
Installation command, such as npm install
, can be omitted if not required.
By default, it executes npm install --prefer-offline --no-audit --progress=false
in the mini-program directory.
commands.build
Build command, such as npm run build
, can be omitted if not required.
localPath
Optional. The local path of the Mini Program project's project.config.json
, default ./
ignores
Optional. File paths to ignore during Mini Program application deployment, supports wildcards, default ["node_modules/**/*"]
deployMode
Optional. The deployment mode for the Mini Program application, supports 2 deployment modes: preview|upload
previewOptions
When
deployModeis set to
preview,
previewOptions` must be provided, which should be an object.
Property Name | Type | Required | Description |
---|---|---|---|
desc | String | No | Version description of the Mini Program application |
setting | IMiniProgramBuildSetting object | No | Compilation settings for the Mini Program application |
qrcodeOutputPath | String | No | Local path to save the generated preview QR code |
pagePath | String | No | Preview page path of the Mini Program application |
searchQuery | String | No | Preview page parameters for the Mini Program application |
scene | Number | No | Preview page scene value for the Mini Program application |
Example:
{
"envId": "{{envId}}",
"framework": {
"plugins": {
"client": {
"use": "@cloudbase/framework-plugin-mp",
"inputs": {
"appid": "",
"privateKey": "",
"localPath": "./",
"ignores": ["node_modules/**/*"],
"deployMode": "preview",
"previewOptions": {
"desc": "One-click preview",
"setting": {
"es6": false
},
"qrcodeOutputPath": "./qrcode.jpg",
"pagePath": "pages/index/index",
"searchQuery": "",
"scene": 1011
}
}
}
}
}
}
uploadOptions
When
deployModeis set to
upload,
uploadOptions` must be provided, which should be an object.
Property Name | Type | Required | Description |
---|---|---|---|
version | String object | No | The version number uploaded for the Mini Program application |
desc | String object | No | Version description for the Mini Program application |
setting | IMiniProgramBuildSetting object | No | Build settings for the Mini Program application |
Example:
{
"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 one-click upload",
"setting": {
"es6": false
}
}
}
}
}
}
}
More Plugins
Please visit the CloudBase Framework Plugin List to use other plugins in combination
Documentation Resources
- CloudBase official website: https://tcb.cloud.tencent.com/
- CloudBase Static Website Setup Guide: https://docs.cloudbase.net/hosting/
- CloudBase Console: https://console.cloud.tencent.com/tcb