gulp-remove-code
gulp-remove-code copied to clipboard
Remove a single line of code with a single line comment.
Remove a single line of code with a single line comment.
The format of the comment is commentStart + removeSingleIf(conditions) + commentEnd
Example
Remove code from JavaScript files
let value = JSON.stringify({key: 'value'}); //removeSingleIf(production)
//removeIf(production)
value = JSON.stringify({key: 'value', production: true}, null, 2);
//endRemoveIf(production)
//removeIf(!development)
value = JSON.stringify({key: 'value', development: false}, null, 2);
//endRemoveIf(!development)
const removeCode = require('gulp-remove-code');
gulp.src('./src/file.js')
.pipe(removeCode({ production: true }))
.pipe(gulp.dest('./dist'))
Then, the code will change to:
//removeIf(!development)
value = JSON.stringify({key: 'value', development: false}, null, 2);
//endRemoveIf(!development)
Remove code from HTML files
<div>
<!--removeIf(production)-->
<div class="sandbox-banner">Running in sandbox environment</div>
<!--endRemoveIf(production)-->
<span>Removing single line code is easy.</span>
<span>Removing single line code is easy.</span> <!--removeSingleIf(production)-->
</div>
Then, the code will change to:
<div>
<span>Removing single line code is easy.</span>
</div>
Hi, @jiangyanfu.
You forgot to update README.md with this changes.