Cocos2d-JS: How to separate the game engine and my game code?

Hi, I’ve been in HTML5 gamedev for a while and have been separating my own game engine and my game code, and used my own compiler to make it work that way.

Now I’m migrating to Cocos2d-JS and tried to compile a default new project with cocos compile -p web -m release. I can see the final result is on publish/html5, but JS code become game.min.js, which includes cocos engine, app + resource.js files, my source files, and main.js.

My problem is, I want to separate this game.min.js into 2 parts; cocos game engine as its own external script and then followed with another script containing my own game code that includes my JS files and the provided app + resouce + main JS files on my own implementation so it becomes like this:

...
<script type='text/javascript' src='res/cocos2d-js-v3.7-min.js'></script>
<script type='text/javascript' src='res/my.game.code.js'></script>
...

I can find my own workaround on producing the engine from the cocos2d-html5 build.xml and make my script to produce it directly, but I can’t find a way to separate the whole game.min.js.
I’ve tried to mess up with the genBuildXml.xml, publish.js, and the build.xml template in /frameworks/cocos2d-html5/tools folder to not combine the game engine also the main.js, but I couldn’t make them work.

Lastly, please let me know if this is not recommended for reasons like messing up the native compilation and such.

Thanks!

Nvm guys. I ended up embedding my the cocos2d project into my own web compiler and skip the cocos’ web compiler, and then automatically transfer all the JS code to cocos2d to be compiled for native only.
Dividing the codes by modifying Cocos tools seems dangerous (One example, I just found out main.js file is used to compile the native), so I’m trying to keep it as it is.

Besides, I don’t know why Cocos web server can’t be opened on LAN, therefore I can’t directly open on my phone (again, nor I want to modify the tools), and I need to clear my cache very often to refresh the game, so I can’t really rely on Cocos web compiler. I hope there are rooms to improve on this side.

Thanks again!