ArkUI项目打包

打包工具:ets2bundle
工具仓库:https://gitee.com/openharmony/developtools_ace_ets2bundle
依赖仓库:https://gitee.com/openharmony/interface_sdk-js

工具初始化

1、配置工具依赖
interface_sdk-js仓库为此工具提供组件类型信息,在打包脚本中需要正确配置

"scripts": {
    "build": "npm run generateDeclarations && ./node_modules/.bin/babel ./src --out-dir lib --extensions .ts && node uglify-source.js lib",
    "generateDeclarations": "node ./build_declarations_file.js ../../interface_sdk-js/api/@internal/component/ets ./declarations ./lib",
}

2、配置本地组件依赖

"dependencies": {
  	"typescript": "file:./deps/ohos-typescript-4.2.3-r2.tgz",
    "arkguard": "file:./deps/arkguard-1.0.0.tgz"
}

3、下载依赖+编译

$ npm install
$ npm run build

工具使用

工具位于developtools_ace_ets2bundle/compiler目录。

1、创建arkui工程

$ npm run create xxxx

2、编译工程

$ npm run compile

其他配置

1、打包ViewPU
默认打包出来的继承View,修改manifest.json文件中的minPlatformVersion值为9,是数字9,即可实现打包出来的View继承ViewPU。或者直接修改create.ts文件,将默认的1.0.1字符串修改是数字9也可以。

  "appID": "com.example.` + appID + `",
  "appName": "` + appName + `",
  "versionName": "1.0.0",
  "versionCode": 1,
  //"minPlatformVersion": "1.0.1",
  "minPlatformVersion": 9,
  "pages": [
    "pages/index"
  ],

2、修改编译默认地址
默认的项目地址在compiler目录下,如果在其他地方,可修改webpack.config.js文件中projectPath值,到指定目录

  if (args.indexOf('projectName') === args.length - 2) {
    // projectConfig.projectPath = path.join(process.cwd(), args[args.length - 1]);
    projectConfig.projectPath = path.join("/home/client/Desktop", args[args.length - 1]);
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值