在底部注入三个具体的文件 [英] injecting many files with three specific at bottom

查看:149
本文介绍了在底部注入三个具体的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要注入所有文件,并重新注入最后三个,all.css,foo.css和app.min.js,以便最后注入它们。
注入任务:

I need to inject all the files,and reinject the last three, all.css, foo.css and app.min.js so they are injected last. Injecting task :

return gulp.src('src/index.html')
        .pipe(inject(gulp.src(['temp/**/*.css','!temp/**/all.css','!temp/**/foo.css','./temp/**/*.js','!temp/**/app.min.js'], {read: false}), {ignorePath: 'temp'} ))
        .pipe(inject(gulp.src(['temp/**/all.css','temp/**/foo.css,'temp/**/app.min.js'], {read: false}), {ignorePath: 'temp'} ))    
        .pipe(gulp.dest('temp'))
        .pipe(connect.reload());
}

我做到了这一点,它只是覆盖了我的第一次注入并仅注入第二个。

The way that i made it, it just overrides my first injection and injects only the second one.

推荐答案

您需要注入一个流。这意味着您需要将第二个流中的文件添加到第一个流的末尾。 gulp-add-src 包让你这么做:

You need to inject a single stream. That means you need to add the files from your second stream to the end of the first stream. The gulp-add-src package let's you do that:

var addSrc = require('gulp-add-src');

var files = gulp.src(['temp/**/*.css','!temp/**/all.css','!temp/**/foo.css','./temp/**/*.js','!temp/**/app.min.js'], {read: false})
 .pipe(addSrc.append(['temp/**/all.css','temp/**/foo.css','temp/**/app.min.js'], {read: false}));

return gulp.src('src/index.html')
  .pipe(inject(files, {ignorePath: 'temp'}))
  .pipe(gulp.dest('temp'))
  .pipe(connect.reload());

这篇关于在底部注入三个具体的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆