gulp-remove-code
A Gulp plugin to remove sections of code from files based on conditions
Install
npm install gulp-remove-code --save-dev
Usage
const removeCode = ; gulp gulp gulp
Examples
Remove code from HTML files
<!--removeIf(production)--> Running in sandbox environment <!--endRemoveIf(production)--> Removing code is easy.
const removeCode = ; gulp
The plugin will remove the code inside the comments, as well as the comments.
Remove code JavaScript files
let value = JSON; //removeIf(production)value = JSON;//endRemoveIf(production) //removeIf(!development)value = JSON;//endRemoveIf(!development)
const removeCode = ; gulp
The plugin will remove the code inside the comments, as well as the comments.
Advanced usage
Starting with version 2 of this plugin, conditions can also be expressed using the !
specifier.
// Remove code using *!* (negated) conditions //----------- gulpfile.js -----------//const removeCode = ; gulp //----------- app-file.js -----------////removeIf(!production)value = JSON;//endRemoveIf(!production)
API
removeCode([options])
options
Type: Object
A key value pair map to specify what code should be removed. The truthy values will remove the code.
options.commentStart
Type: String
Default: Detected from file extension. Use // as fallback.
Configure how the start comment is defined.
options.commentEnd
Type: String
Default: Detected from file extension. Use empty as fallback.
Configure how the end comment is defined.
License
MIT © Cristian Trifan