在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):crissdev/gulp-remove-code开源软件地址(OpenSource Url):https://github.com/crissdev/gulp-remove-code开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-remove-code
Installnpm install gulp-remove-code --save-dev Usageconst removeCode = require('gulp-remove-code');
gulp.src('./src/*.js')
.pipe(removeCode({ noDevFeatures: true }))
.pipe(gulp.dest('./dist/'))
gulp.src('./src/*.js')
.pipe(removeCode({ noDevFeatures: true, commentStart: '/*', commentEnd: '*/' }))
.pipe(gulp.dest('./dist/'))
gulp.src('./src/*.coffee')
.pipe(removeCode({ noDevFeatures: true }))
.pipe(gulp.dest('./dist/')) ExamplesRemove code from HTML files<div>
<!--removeIf(production)-->
<div class="sandbox-banner">Running in sandbox environment</div>
<!--endRemoveIf(production)-->
<span>Removing code is easy.</span>
</div> const removeCode = require('gulp-remove-code');
gulp.src('./src/file.html')
.pipe(removeCode({ production: true }))
.pipe(gulp.dest('./dist')) The plugin will remove the code inside the comments, as well as the comments. Remove code JavaScript fileslet value = JSON.stringify({key: 'value'});
//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')) The plugin will remove the code inside the comments, as well as the comments. Advanced usageStarting with version 2 of this plugin, conditions can also be expressed using the // Remove code using *!* (negated) conditions
//----------- gulpfile.js -----------
//
const removeCode = require('gulp-remove-code');
gulp.src('./src/file.js')
.pipe(removeCode({ production: false }))
.pipe(gulp.dest('./dist'))
//----------- app-file.js -----------
//
//removeIf(!production)
value = JSON.stringify({key: 'value', production: false}, null, 2);
//endRemoveIf(!production) APIremoveCode([options])optionsType: A key value pair map to specify what code should be removed. The truthy values will remove the code. options.commentStartType: Default: Configure how the start comment is defined. options.commentEndType: Default: Configure how the end comment is defined. LicenseMIT © Cristian Trifan |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论