Build 项目构建, 希望resources文件夹下某一个指定子目录不构建

如题,
我希望在构建的时候,删除resources文件夹下一个子文件夹,因为这个文件夹的资源是我调试的用途,构建之后会使用另外的目录代替。

现在每次构建时,先把resources下那个子文件夹移除,再Build,完了在拷贝回来,很费事。有没有办法?

现在使用的时Creator1.10.1版本,看了一下文档中《定制项目构建流程》,正常发布后的目录完全错乱,也没法通过脚本解决,有大神遇到类似的问题吗?

@jare

要是能够有个配置文件之类的字段,指定一个 “exclude” 那就完美了。

可以在构建后,删掉不想要的 native asset,参考 《定制项目构建流程》 最下面的 demo

写一个构建的脚本,用命令行构建,这样拷贝就简单了

demo我下了研究了一下,可能是1.10.1版本的不兼容,这里报错(没有此buildResults属性):

// 通过 options.buildResults 访问 BuildResults
var buildResults = options.buildResults;

然后我打印了全部的options对象,结果如下,确实没有:

{
“actualPlatform”: “Web Mobile”,
“apiLevel”: “”,
“appABIs”: [ ],
“appKey”: “”,
“appSecret”: “”,
“buildPath”: “/Users/junlas/Documents/projects/Github.com/demo-process-build-textures/build”,
“debug”: false,
“dest”: “/Users/junlas/Documents/projects/Github.com/demo-process-build-textures/build/web-mobile”,
“embedWebDebugger”: false,
“encryptJs”: true,
“excludeScenes”: [ ],
“excludedModules”: [ ],
“fb-instant-games”: { },
“includeAnySDK”: false,
“includeSDKBox”: false,
“inlineSpriteFrames”: true,
“inlineSpriteFrames_native”: true,
“jailbreakPlatform”: false,
“md5Cache”: false,
“mergeStartScene”: false,
“oauthLoginServer”: “”,
“optimizeHotUpdate”: false,
“orientation”: {
“landscapeLeft”: true,
“landscapeRight”: true,
“portrait”: false,
“upsideDown”: false
},
“packageName”: “org.cocos2d.test-build-textures”,
“platform”: “web-mobile”,
“previewHeight”: “720”,
“previewWidth”: “1280”,
“privateKey”: “”,
“qqplay”: {
“REMOTE_SERVER_ROOT”: “”,
“orientation”: “portrait”
},
“renderMode”: “0”,
“scenes”: [
“20d747f8-f31e-4d5a-8605-cb04ccdc3a97”
],
“sourceMaps”: false,
“startScene”: “20d747f8-f31e-4d5a-8605-cb04ccdc3a97”,
“template”: “link”,
“title”: “test-build-textures”,
“useDebugKeystore”: true,
“vsVersion”: “auto”,
“webOrientation”: “auto”,
“wechatgame”: {
“REMOTE_SERVER_ROOT”: “”,
“appid”: “wx6ac3f5090a6b99c5”,
“isSubdomain”: false,
“orientation”: “portrait”,
“subContext”: “”
},
“xxteaKey”: “51856d77-2004-41”,
“zipCompressJs”: true,
“project”: “/Users/junlas/Documents/projects/Github.com/demo-process-build-textures”,
“projectName”: “test-build-textures”,
“debugBuildWorker”: false
}

你看的是 2.0 的文档吧…… 1.10 不支持 BuildResults…… 非常抱歉

请问 buildResults api 在哪里呢??
实在找不到

还有非resources目录的 auto-atlas,构建后找不到对应关系。
@jare

2.0.7 将会修复

:+1:

请问2.X 如何抓到构建后的auto-atlas uuid?
文件里没说明清楚呀!!!
@jare

编辑器提供了很多全局变量(CC_Editor,CC_Preview等)
项目build的时候会treeshake(剔除死代码),
举个栗子:
assets/resources/gm.js中有这样一段代码

if(CC_Editor){
    cc.log('oh~~ my god, GM!!!');
}

资源目前没有啥好的剔除办法
这也是你build之后,看不到引擎CC_Editor相关的逻辑

如果以上还满足不了你的需求,这里再提供几个思路:

  • 监听build消息自行处理
  • 可以写个脚本,配合命令行构建项目,处理这个特殊的文件夹
  • 可以考虑将不想参与构建的代码独立出来,变成一个小项目,放在项目外边,代码通过rollup打包,再配合命令行构建即可
1赞

可以参考通用渐进式游戏客户端开发框架:EasyGameFramework持续更新贴

提供简易完善的rollup打包工具:egf-cli

1赞