Exclude debug JavaScript code during minification

后端 未结 11 2023
庸人自扰
庸人自扰 2020-11-28 07:16

I\'m looking into different ways to minify my JavaScript code including the regular JSMin, Packer, and YUI solutions. I\'m really interested in the new Google Closure Compil

11条回答
  •  忘掉有多难
    2020-11-28 07:32

    A good solution in this case might be js-build-tools which supports 'conditional compilation'.

    In short you can use comments such as

    // #ifdef debug
    var trace = debug.getTracer("easyXDM.Rpc");
    trace("constructor");
    // #endif
    

    where you define a pragma such as debug.

    Then when building it (it has an ant-task)

    //this file will not have the debug code
    
    //this file will        
    
    

提交回复
热议问题