JThora JThora - 4 years ago 100
Javascript Question

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


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
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.


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.


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
and compiling down into Javascript
with a
. I am definitely compiling down the Typescript to Javascript before running the cocos compiler)


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.


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

Is it possible that
makes the
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?

Answer Source

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

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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download