微信小程序打包
最后更新于:2022-04-02 07:22:43
#### 打包为微信小程序
1. 申请微信小程序AppID,参考:微信教程【https://developers.weixin.qq.com/miniprogram/dev/framework/quickstart/getstart.html#%E7%94%B3%E8%AF%B7%E5%B8%90%E5%8F%B7】。
2. 在HBuilderX中顶部菜单上依次单击“发行” =>“小程序-微信”,输入小程序名称和appid单击发行即可在unpackage/dist/build/mp-weixin生成微信小程序项目代码。
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/6e/2c/6e2c306c9674accc64ec8f5d24e14c06_1920x1080.png)
输入小程序的appid和名称
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/98/76/9876b1aaa9699ef1cd97e1cea67ec568_833x397.png)
发行后在微信开发者工具中打开,
**要注意小程序的合法域名的配置。以及微信小程序域名必须https开头**
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/fd/ec/fdec91f7e7c2655f8f21e5c12b36b607_1919x748.png)
小程序配置域名白名单:https://blog.csdn.net/weixin_44606457/article/details/105227254
注意:
因为小程序打包上传大小不能超过2048kb,所以在上传是需要对部分静态文件进行删除
1.打开打包文件夹
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/b2/d1/b2d15e18eb376e02ab7f146e302904a9_1311x693.png)
2.打开static文件
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/c7/af/c7af19209f34ba0b01ec5bf73832a937_385x263.png)
3.删除下图圈中说明的文件夹
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/c4/a4/c4a4b9b1fa8629b8d484cfcf0fe63c2d_1499x374.png)
4.然后我们在上传才符合小程序要求的大小
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/f8/c2/f8c2baa13ee679a5ba4215ae878648b5_433x151.png)
另外一种方式:目录条件编译:
https://uniapp.dcloud.io/platform?id=static-%e7%9b%ae%e5%bd%95%e7%9a%84%e6%9d%a1%e4%bb%b6%e7%bc%96%e8%af%91
';