I was wondering if there was a way I can change variables based on the title of the build or in some other way external to the compiled code. For example it would be good if my ‘show_debug’ variable is set to true if the build title contains the word ‘debug’.
Or maybe there is some other way I can do this that already exists?
Check the current page URL. If it starts with launch.playcanvas.com then set the variable to true
Check URL params for debug
Create a release branch that only has the change of this variable set to false. And merge your development branch to it before building a release
Have debug code between comments blocks like // DEBUG_START and // DEBUG_END. Don’t minify your code on publish and use a post build script that takes the __game-scripts__.js file, strips code out between those comment blocks and minifies the code.
For future reference the final code for checking against current url is:
//get current url
var url = new URL(window.top.location.href);
//check if current url contains "launch.playcanvas.com" or whatever you want
this.is_hosted_on_playcanvas=url.toString().includes("launch.playcanvas.com");
//Show debug only if we are hosted at Playcanvas
if(this.is_hosted_on_playcanvas==false)
{
this.show_debug=false;
}