Search code examples
javascriptdebuggingminify

How to get rid of unnecessary debugging code in JavaScript during the compilation/minification process?


I used to write lots of debug code in the JavaScript app and I’m looking for a technique that allows to get rid of debug code during the compilation/minification process.

Is there in JavaScript World some equivalent of compilation directives in C/C++?

In C/C++ it looks like this:

#ifdef _DEBUG
counter++;
#endif

PS. Currently, I use gulp


Solution

  • i think what you are trying to do is available using a task runner such as grunt or gulp. both of this tools are a task runner that convert your code, using plugin, to do this kind of manipulation.

    such of this so called "plugin" is gulp-preprocess. this plugin doing what you are asking :)

    for more understand of gulp you can go to the gulp site or find some good tutorials on the web...