chriskelly
chriskelly

Reputation: 7736

gulp watch copying files twice to different locations

Since yesterday something strange has started happening with my gulp-watch task. Afaik, all I did was change the destination but I can reproduce with the simple gulpfile posted below:

I have a file structure like this:

src/html/stuff/file.html
src/js/something/file.js

Whenever there is a change I want it relflected in the build folder but when I run the gulp watch:stuff below I get the following output:

build/html/stuff/file.html
build/stuff/file.html
build/js/something/file.js

gulpfile

var gulp = require('gulp');
var watch = require('gulp-watch');

gulp.task('watch:stuff', function () {
    var pattern = ['src/html/**/*.html', 'src/js/**/*.js'];

    gulp.src(pattern, { base : './src/' })
    .pipe(watch({glob: pattern, emit : 'all', verbose: true},
                function(files) {
                    files.pipe(gulp.dest('./build'));
                }
               )
         );
});

Using gulp(3.8.8), gulp-watch(0.7.0)

Upvotes: 0

Views: 882

Answers (1)

user3995789
user3995789

Reputation: 3460

remove the base option, probably It confuses the gulp.src somehow, I don't know.

Upvotes: 1

Related Questions