在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):bruderstein/gulp-html-src开源软件地址(OpenSource Url):https://github.com/bruderstein/gulp-html-src开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):#gulp-html-src Convert the HTML input to all the linked script or link/css tags Streams are supported. (It will emit whatever it gets - i.e. streams in, streams out; Buffer in, Buffer out) UsageInstall
Examplevar gulp = require('gulp');
var ghtmlSrc = require('gulp-html-src');
var uglify = require('gulp-uglify');
gulp.task('copy-js', function() {
gulp.src('./src/*.html')
.pipe(ghtmlSrc())
// From this point, it's as if you'd used gulp.src() listing each of your
// javascript files that are in your html as <script src="..."></script>
.pipe(uglify())
.pipe(gulp.dest('./build/'));
});
gulp.task('copy-css', function() {
gulp.src('./src/*.html')
.pipe(ghtmlSrc({ presets: 'css'}))
.pipe(gulp.dest('./build/'));
}); OptionsBasic usage
You can use the It will skip any script or link tags with data-remove="true" or data-ignore="true" set. You can then use these tags to control what to remove when you remove the script tags from your HTML later. options.presets
options.includeHtmlInOutput
By default the original HTML file (that probably came from gulp.src()) is swallowed by Advanced usageThe following options are not used for the "normal" cases, but could be useful if you want to do something more advanced (for instance select all images out of an HTML file). These options individually override the presets, so it's perfectly fine to specify options.selector
This is the cheerio selector (basically a jQuery selector) for the elements to select. See options.getFileName
This function is called with each matching element from the function getFileName(node) {
return node.attr('src');
} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论