A little late, but I needed the same thing and could not refuse until a viable solution.
I have a kind of "main" javascript file, where I have a line like:
Site.DEBUG = false;
Then in the code I can check this constant. Now I had to decide that during the build some kind of automation would set this for me according to the configuration of the project. Here I found fnr.exe command line tool for searching and replacing in files. This is a good utility, it would be worth checking anyway. So, at the moment I created a folder in the project directory with the name BuildScripts , I copied the fnr.exe file into it and created such a batch file.
switch_client_debug.bat REM Params: path to folder, filename, change-DEBUG-from-this, to-this fnr.exe --cl --dir "%1" --fileMask "%2" --caseSensitive --showEncoding --find "DEBUG = %3" --replace "DEBUG = %4"
Then I defined the appropriate pre-build events in the web project as follows:
cd $(ProjectDir)BuildScripts call switch_client_debug.bat $(ProjectDir)ts site.ts false true
and its pair in Release config:
cd $(ProjectDir)BuildScripts call switch_client_debug.bat $(ProjectDir)ts site.ts true false
Now everything works like a charm, and I have the ability to log, track, special logic to configure Debug and for Release in Javascript.
source share