klei/gulp-inject

gulp-inject says to me "Nothing to inject"

DennisBoanini opened this issue · 0 comments

I have this gulp file

var gulp = require('gulp'),
	browserSync = require('browser-sync').create(),
	sass = require('gulp-sass'),
	bower = require('gulp-bower'),
	inject = require('gulp-inject'),
	mainBowerFiles = require('main-bower-files');

gulp.task('browser-sync', ['sass'], function(){
	browserSync.init({
		server: "./app",
		notify: false,
		port: 8080,
		ui: {
			port:8081
		}
	});
});

gulp.task('watch', ['bower', 'browser-sync'], function(){
	gulp.watch("app/scss/*.scss", ['sass']);
	gulp.watch("bower.json", ['bower-inject']);
	gulp.watch("app/js/*.js").on('change', browserSync.reload);
	gulp.watch("app/*.html").on('change', browserSync.reload);
});

gulp.task('sass', function(){
	return gulp.src("app/scss/*.scss")
		.pipe(sass())
		.pipe(gulp.dest("app/css"))
		.pipe(browserSync.stream());
});

gulp.task('default', ['watch']);

gulp.task('bower', function(){
	return bower();
});

gulp.task('bower-inject', function(){
	return gulp.src('app/index.html')
    .pipe(inject(gulp.src(mainBowerFiles(), {read: false}), {name: 'bower'}))
    .pipe(inject(gulp.src('app/**/*.{css,js}', {read: false}), {relative: true}))
    .pipe(gulp.dest('app'));
});

when I install a dependencies with bower the console show me this message

[17:11:07] Starting 'bower-inject'...
[17:11:07] gulp-inject Nothing to inject into index.html.
[17:11:07] gulp-inject Nothing to inject into index.html.
[17:11:07] Finished 'bower-inject' after 22 ms
[BS] Reloading Browsers...
[17:17:11] Starting 'sass'...
[BS] 2 files changed (hhhh.css, main.css)
[17:17:11] Finished 'sass' after 11 ms

and nothing is injected in the index page, that have this form

<!doctype html>
<html>
<head>
	<title>GULP TEST</title>
	<!-- bower:css -->
	<!-- endbower -->
</head>
<body>
	<!-- bower:js -->
	<!-- endbower -->
</body>
</html>

This my folder structure
Schermata del 2017-06-07 17-24-48.png