46
46

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gulp.watchはパスを./で始めると新規ファイルを処理しない

Posted at

以下のようなbrowserifyするだけのgulpfile.jsは、よくある感じに見えるが、新しく.jsファイルが増えてもbrowserifyしてくれない。

var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var source = require("vinyl-source-stream");

gulp.task('browserify', function(){
    return browserify('./js/main.js')
        .bundle()
        .on('error', function(err) {
            gutil.log(err);
            this.emit('end');
        })
        .pipe(source("app.js"))
        .pipe(gulp.dest('./dist'));
});

gulp.task('watch', function(){
    gulp.watch('./js/*.js', ['browserify']);  // ここがポイント
});

こうするとよい:

var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var source = require("vinyl-source-stream");

gulp.task('browserify', function(){
    return browserify('./js/main.js')
        .bundle()
        .on('error', function(err) {
            gutil.log(err);
            this.emit('end');
        })
        .pipe(source("app.js"))
        .pipe(gulp.dest('./dist'));
});

gulp.task('watch', function(){
    gulp.watch('js/*.js', ['browserify']);
});

参考
https://github.com/sindresorhus/gulp-ruby-sass/issues/11

46
46
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
46

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?