javascript - gulp.watch() not running subsequent task -
running bizarre bug when trying create modular gulp tasks splitting them separate files. next should execute task css
, not:
watch.js
var gulp = require('gulp'); var plugins = require('gulp-load-plugins')(); gulp.task('watch', function () { plugins.watch('assets/styl/**/*.styl', ['css']); // problem });
declaring ['css']
in plugins.watch()
should technically run next task next:
css.js
var gulp = require('gulp'); var plugins = require('gulp-load-plugins')(); gulp.task('css', function () { homecoming gulp.src('assets/styl/*.styl') .pipe(plugins.stylus()) .pipe(gulp.dest('/assets/css')); });
file: gulpfile.js
var gulp = require('gulp'); var requiredir = require('require-dir'); requiredir('./gulp/tasks', { recurse: true }); gulp.task('develop', ['css', 'watch']);
folder structure - gulp/ - tasks/ - css.js - watch.js - gulpfile.js
gulp develop
should run tasks css
, watch
(it does). on file changes, watch
should observe them (it does) , run css
task (it's not).
not terribly fond of solution gulp.start()
beingness deprecated in next release, prepare it:
watch.js
plugins.watch('assets/styl/**/*.styl', function() { gulp.start('css'); });
either utilize gulp's builtin watch syntax:
gulp.task('watch', function () { gulp.watch('assets/styl/**/*.styl', ['css']); });
or gulp-watch plugin syntax:
gulp.task('watch', function () { plugins.watch('assets/styl/**/*.styl', function (files, cb) { gulp.start('css', cb); }); });
there's typo in gulp.dest path. alter relative:
.pipe(gulp.dest('assets/css'));
javascript frontend gulp
No comments:
Post a Comment