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 mands 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 piler. Old code that I've recently changed still exists in newly piled cocos2d projects. I cannot detect changes I've made to class files that have already been piled.
Technical:
The problem technically: Modified .js files are not being copied correctly by the cocos2d-js piler (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 piling down into Javascript .js
with a .js.map
. I am definitely piling down the Typescript to Javascript before running the cocos piler)
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 pile
or cocos run
mands to overwrite old any .js files, instead of 'intelligently' retaining old files?
Is it possible that --source-map
makes the run
mand 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?
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 mands 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 piler. Old code that I've recently changed still exists in newly piled cocos2d projects. I cannot detect changes I've made to class files that have already been piled.
Technical:
The problem technically: Modified .js files are not being copied correctly by the cocos2d-js piler (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 piling down into Javascript .js
with a .js.map
. I am definitely piling down the Typescript to Javascript before running the cocos piler)
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 pile
or cocos run
mands to overwrite old any .js files, instead of 'intelligently' retaining old files?
Is it possible that --source-map
makes the run
mand 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?
Share Improve this question edited May 16, 2014 at 19:12 CodeSmile 64.5k20 gold badges134 silver badges219 bronze badges asked May 16, 2014 at 18:31 Jordan TranaJordan Trana 1,5163 gold badges20 silver badges30 bronze badges4 Answers
Reset to default 7Fix 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)
You should know, Chrome is tenacious about caching.
You can turn it off every way they offer, and it will still retain js files you don't want it to.
My advice is to restart your entire browser--not just the tab you're debugging--at least once an hour.
Yes it was as simple as this, just open the dev tools with F12, then go to settings, do the cache thing, and when you run your game , activate the dev tools again (F12) and refresh the page
You can set noCache to true in your project.json file if you don't want caching anymore
Here is the sample code.
{
"project_type": "javascript",
"debugMode": 1,
"showFPS": false,
"frameRate": 60,
"noCache": true,
"id": "gameCanvas",
"renderMode":1,
"engineDir": "frameworks/cocos2d-html5",
"modules": [
"cocos2d",
"cocostudio",
"editbox"
],