btfly-gulp-conditional-compile
A Gulp plugin to optionally remove js-conditional-compile-loader comments from your code that follow a particular pattern. Useful for JavaScript builds.
Installation
cnpm i btfly-gulp-conditional-compile --save-dev
Simple Usage
Import like const jsConditionalCompile = require("btfly-gulp-conditional-compile");
. Pass a simple config object to jsConditionalCompile()
in your Gulp pipe. All the properties of the objects represent js conditional compile tags. Set to false to remove them.
The system will look for sections of code that have this signature:
// To remove this section use: jsConditionalCompile({ debug: false })
// /* pragma:DEBUG_START */
// var a = true;
// console.warn("a is", a);
// /* pragma:DEBUG_END */
// To remove this section use: jsConditionalCompile({ amd: false })
// /* pragma:AMD_START */
// var a = true;
// console.warn("a is", a);
// /* pragma:AMD_END */
// To remove this section use: jsConditionalCompile({ thatComponents: process.env.ENV_CONDITIONAL_COMPILE_thatComponents === false})
/* IFTRUE_thatComponents */
var a = true;
console.warn('a is', a);
/* FITRUE_thatComponents */
Use in your gulpfile:
var jsConditionalCompile = require('btfly-gulp-conditional-compile');
gulp.src(['/**/*.js']).pipe(
jsConditionalCompile({
// debug: false,
thatComponents: false,
})
);
Note: Its recommended you run this on your concatenated stream rather than your split-up file stream for performance reasons.