gulp-inject will only enter one set of files, replacing the old set with a new set every time you call it. There are two ways to solve the problem.
1) On the gulp-inject github: page, use the event-stream plugin to combine the two file name streams (.css and .js) into one stream that you pass for input.
var es = require('event-stream'), inject = require('gulp-inject'); // Concatenate vendor scripts var vendorStream = gulp.src(['./src/vendors/*.js']) .pipe(concat('vendors.js')) .pipe(gulp.dest('./dist')); // Concatenate AND minify app sources var appStream = gulp.src(['./src/app/*.js']) .pipe(concat('app.js')) .pipe(uglify()) .pipe(gulp.dest('./dist')); gulp.src('./src/index.html') .pipe(inject(es.merge(vendorStream, appStream))) .pipe(gulp.dest('./dist'));
2) An alternative solution that might suit your current code organization better is to use the gulp-inject name parameter to define two different places for input. So you have a header file:
<!DOCTYPE html> <html> <head> <title>My index</title> </head> <body> </body> </html>
and then your gulpfile.js contains something like:
var inject = require('gulp-inject'); gulp.src('./src/index.html') .pipe(inject(gulp.src('./config.css'), {name: 'styles'})) .pipe(inject(gulp.src('./config.js'), {name: 'scripts'})) .pipe(gulp.dest('./dist'));
source share