# polea `laya cmd编译工具`
# 介绍
```
使用 esbuild 来增量构建 layabox 项目 修改代码后立即就能看到效果 提高开发速度,优化开发体验。
```
> ### 基于一下原因开发了这款工具
>
> * 由于 Laya 官方提供的命里行工具不兼容 node 版本
> * 无法忍受 LayaAir 编译一次项目需要等待到50-70s 左右的时间
> ### 特性
> * 使用 esBuild 加快编译速度
> * 高度可定制化(可以用于非 Laya 项目中)
> * 开箱即用
----------
## 关于 esBuild
- <a href="https://github.com/evanw/esbuild/">esbuild</a> 是一个用 Go 语言编写的用于打包,压缩 Javascript 代码的工具库。它最突出的特点就是速度极快,下图是 esbuild 跟 webpack, rollup, Parcel 等打包工具打包效率的一个比较:
<img src="./res/contrast.png">
图片取自 <a href="https://github.com/evanw/esbuild/">esbuild Github 仓库</a>。
为什么它能做到那么快?
它是用 Go 语言编写的。
该语言可以编译为本地代码解析,生成最终打包文件和生成 source maps 的操作全部完全并行化,无需昂贵的数据转换,只需很少的几步即可完成所有操作。
该库以提高编译速度为编写代码时的第一原则,并尽量避免不必要的内存分配。
更多详细介绍,详见 Breword 翻译的 <a href="https://www.breword.com/evanw-esbuild">esbuild 官方文档</a>;
## 对比其它工具
| 工具类型 | 简介 | 修改代码后需要等多久才能刷新浏览器并看到修改后的效果 | 是否支持断点调试 | 推荐度 |
| :----------- | :----------------------------------------------: | :--------------------------------------------------: | :--------------: | :--------: |
| layaAir | 手动点击编译 | 一年,很慢 | 不支持 | 强烈不推荐 |
| layaair2-cmd | 跟第一步差不多,就是加了个自动编译 | 半年,慢 | 支持 | 不推荐 |
| webpack | 自动编译,功能强大,但是项目比较大的话还是会很慢 | 一天,稍快 | 支持 | 推荐 |
| **本工具** | 自动构建,不编译,项目再大都没影响 | 0秒,飞快,切换到浏览器刷新的速度有多快它就有多快 | 支持 | 强烈推荐 |
# 安装 `polea`
```shell
npm i -g polea
```
> 可以使用以下命令查看
```shell
polea -h
```
>> ---
# 使用 【初始化】
```
polea init
```
> 命令执行后,会在项目目录下生成 `.polea` 文件夹
>
> .polea 目录下默认会生成两个 `config.*.ts/config.ts` 文件
>> ----
# 使用 【编译、发布】
> 制定自己的【编译/发布】流程请参考 config.ts和 config.polea.ts 这两个文件
>
> 注意 其中 compile编译命令 可以替换成 publish 发布命令
```shell
polea compile //执行的config.ts中的代码
polea compile -p polea //执行config.polea.ts中的代码
```
>> ------
# 使用 Watch
> 配置
```ts
buildConfig: (params: polea.ConfigCommand) => {
let { command } = params;
if (command == "compile") {//polea compile
return {
define: { DEBUG: true, RELEASE: false },
watch: true,//开启监听模式
output: "./bin",
plugins: [new polea.ESBundlePlugin({ sourcemap: true })],
};
} else if (command == "publish") {//polea publish
return {
define: { DEBUG: true, RELEASE: false },
watch: false,
output: "./release/" + getversion(),
plugins: [new polea.ESBundlePlugin({ sourcemap: false, minify: true })],
};
}
}
```
> ### 目前只有代码和资源监听两个插件支持,`目前发布命令不支持监听模式`
* ESBundlePlugin //编译代码插件
* UIPlugin //更新资源插件
# 插件
## 内置插件列表
> 如果需要自定义一个插件请参考`.polea/plugins`下的插件
| 插件名 | 说明 |
| ---- | ---- |
| CleanPlugin | 清理文件插件 |
| CompressJSPlugin | 压缩 js 代码插件 |
| CopyPlugin | 拷贝文件插件 |
| ESBundlePlugin | 编译代码插件 |
| LayadccPlugin | 生成 Layadcc 文件插件 |
| ManifestPlugin | 生成版本信息 |
| UIPlugin | 导出代码、导出ui、合成图片资源到 bin 目录下面 |
## 插件的使用
```ts
buildConfig: (params: polea.ConfigCommand) => {
let { command } = params;
if (command == "compile") {//polea compile
return {
//使用插件
plugins: [
new polea.UIPlugin(),//内置插件
new polea.ESBundlePlugin({ sourcemap: true }),//内置插件
new polea.CleanPlugin(),//内置插件
new layadcc(`xxx`),//自定义的插件
],
};
} else if (command == "publish") {//polea publish
return {};
}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
laya cmd 命令行编译工具.zip
共92个文件
ts:32个
dll:14个
txt:10个
需积分: 5 0 下载量 161 浏览量
2024-01-15
15:03:22
上传
评论
收藏 12.04MB ZIP 举报
温馨提示
软件开发设计:应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络与通信是一个非常广泛的领域,它涉及到计算机科学、电子工程、数学等多个学科的知识。 云计算与大数据:包括云计算平台、大数据分析、人工智能、机器学习等,云计算是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需提供给计算机和其他设备。
资源推荐
资源详情
资源评论
收起资源包目录
laya cmd 命令行编译工具;提高 Laya项目的编译速度;解决Layaair cmd和 Layaair-cmd2无法兼容 node 高低版本的问题。.zip (92个子文件)
cm
.prettierrc 571B
template
plugins
layadcc.ts 522B
diffPlugin.ts 11KB
config.ts 813B
config.polea.ts 326B
api.d.ts 201KB
package.json 169B
getVersion.ts 154B
tsconfig.json 658B
node.d.ts 185KB
src
command.ts 1KB
tool
FileUtil.ts 18KB
config.ts 4KB
net.ts 275B
Utils.ts 1KB
run.ts 227B
builtin
UIPlugin.ts 3KB
CompressJSPlugin.ts 2KB
LayadccPlugin.ts 2KB
ESBundlePlugin.ts 10KB
CleanPlugin.ts 571B
CopyPlugin.ts 3KB
ProcessPlugin.ts 464B
tsconfig.json 6KB
ManifestPlugin.ts 4KB
index.ts 7KB
commands
make.ts 4KB
init.ts 1KB
service.ts 1KB
build.ts 102B
publish.ts 8KB
ui.ts 2KB
compile.ts 2KB
task.ts 780B
index.ts 1KB
libs
genDcc
index.js 8KB
ProjectExportTools
TP
QtGui 5MB
QtCore 5.52MB
Qt5Gui.dll 5.93MB
imageformats
qjpeg.dll 253KB
qsvg.dll 38KB
qtga.dll 37KB
qtiff.dll 449KB
qwebp.dll 450KB
qgif.dll 44KB
qicns.dll 57KB
qwbmp.dll 36KB
qico.dll 47KB
Qt5Core.dll 5.82MB
libwinpthread-1.dll 89KB
atlas-generator 236KB
libstdc++-6.dll 1.48MB
libgcc_s_dw2-1.dll 129KB
atlas-generator.exe 341KB
runcc.bat 151B
CmdConfig.json 37B
data
laya.editorUI.xml 105KB
codeTemplate2
tsCodePre.txt 96B
jsCodeTpl.txt.view 242B
asCodeTpl2.txt 452B
tsTableCodeTpl.txt 66B
jsCodeTpl.txt 278B
gameconfig
GameConfig.json 306B
GameConfig.ts 828B
GameConfig.all 374B
GameConfig.as 1KB
GameConfig.js 755B
asCodeTpl.txt.load 333B
asBase64Tpl.txt 358B
asCodeTpl.txt 391B
jsCodeTpl.txt.preset 320B
jsTableCodeTpl.txt 85B
tsCodeTpl.txt.efc 267B
asCodeTpl.txt.efc 319B
jsCodeTpl.txt.efc 215B
jsCodePre.txt 96B
asTableCodeTpl.txt 77B
asCodeTpl.txt.view 174B
tsCodeTpl.txt.load 325B
tsCodeTpl.txt.view 185B
asCodeTpl.txt.preset 480B
tsCodeTpl.txt 380B
tsCodeTpl.txt.preset 402B
jsCodeTpl.txt.load 236B
LayaAirCmdTool.max.js 3.39MB
libs
LayaAirFileConfigTool
LayaAirFileConfigTool.max.js 1.07MB
res
contrast.png 36KB
package.json 1KB
bin
cli.js 45B
.gitignore 55B
tsconfig.json 6KB
README.md 5KB
共 92 条
- 1
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 一种改进的Goldstei...-InSAR干涉图滤波算法-于晓歆.pdf
- 陈慧琳 - 今生你作伴 [mqms2].mp3
- The Experiment 2 of Engineering Electromagnetics.pdf
- Engineering-Electromagnetic-Theory-Lab-4.pdf
- Engineering electromagnetic theory-1.docx
- The Experiment 4 of Engineering Electromagnetics.pdf
- Engineering-Electromagnetic-Theory-Lab-3.pdf
- The Experiment 3 of Engineering Electromagnetics.pdf
- Engineering electromagnetic theory-2.docx
- tensorflow-gpu-2.7.0-cp37-cp37m-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功