我想多次吞并同一文件,但是{' nounique':true}不起作用
我想按顺序使用Gulp来限制一些HTML文件,其中一些是重复的。
例如:
gulp.task('Generate HTML', function(cb) {
const srcset = [
'header.html',
'content.html',
'section2.html',
'banner-cat.html',
'section3.html',
'banner-cat.html',
'section4.html',
'content.html',
'content.html',
'banner.html',
'footer.html'
];
gulp.src(srcset, {'allowEmpty': true, 'nounique': true, 'nosort': true})
.pipe(concat('index.html'))
.pipe(gulp.dest('public/'));
cb();
});
我在
no-sort /“ rel =“ nofollow noreferrer”>文档所以我认为这可以解决我的问题,但是我没有得到所需的结果,因为每个HTML片段都是 no-Inique
no-sort concat
-ED ,因此任何重复的片段都只会出现一次。
请帮助我提供任何建议,或者如果您知道其他可以帮助我使用Gulp和JavaScript实现这一预期结果的毛刺软件包
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Gulp.Src
将其参数视为Glod模式的列表,而不是文件路径。每个模式都可以匹配一个或多个文件或根本不匹配,如果相同的文件与多个模式匹配,则取决于实现的决定。最好在这里单独加载每个文件,然后加入流。
使用 merge2 ,使用:然后使用:
然后您的代码看起来像这样:
gulp.src
treats its argument as a list of glob patterns rather than file paths. Each pattern could match one or multiple files or none at all, and if the same file is matched by multiple patterns, it's up to the implementation to decide what to do.It's better here to load each file individually and then join the streams.
To use merge2, install the package with:
Then your code could look like this: