Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2D-JS -- Compile and Run a 'Clean' build?

Context:
I'm creating a Cocos2d-JS Game. I have already created the Project and am in development phase.

I can run cocos run -p web or cocos run -p web --source-map from the project directory in the Console. These commands work and allow me to run and test my project.


Problem:
Simply: Code changes I make are not being picked up by the cocos2d-JSB compiler. Old code that I've recently changed still exists in newly compiled cocos2d projects. I cannot detect changes I've made to class files that have already been compiled.


Technical:
The problem technically: Modified .js files are not being copied correctly by the cocos2d-js compiler (from the Terminal/Console). The previous version of the .js file are retained somehow in the localhost-web-server. The localhost is maintained by the Python script that runs the cocos2d app.

(I am writing most of my code using Typescript .ts and compiling down into Javascript .js with a .js.map. I am definitely compiling down the Typescript to Javascript before running the cocos compiler)


More:
I can see my .ts files are visible from the localhost when using Javascript Console in my Chrome Browser. I can also see my .js files this way, and can confirm that the code has not been updated.


Question:
How can I 'Force' the cocos compile or cocos run commands to overwrite old any .js files, instead of 'intelligently' retaining old files?

Is it possible that --source-map makes the run command force a fresh build?

I want to make a 'Clean Build' like in Apple's Xcode, but for cocos2d-js. How can I do this?

If none of that is possible, where can I locate the build/run directory used by the localhost so I can manually update the .js files myself?

like image 604
JThora Avatar asked Mar 19 '23 14:03

JThora


1 Answers

Fix it: .js files were being Cached by my Browser.

Issue:
Chrome Browser was Caching the .js files. I solved this problem by turning off Caching. I did not realize that the localhost was indeed pointing to the project directory.


Solution: Disable Caching in Chrome:
Menu (top right icon) -> Tools -> Developer Tools -> Settings (Gear Icon) -> Checked the box for Disabling Caching (when DevTools is open)

like image 75
JThora Avatar answered Mar 23 '23 18:03

JThora