Z
Z
Zakhar Morozov2016-07-02 19:38:44
Node.js
Zakhar Morozov, 2016-07-02 19:38:44

Why does the gulp plugin not work correctly when called by watch?

I'm not sure if this is specific to a plugin or gulp in general. In general, I use gulp-bem .
I hung spying on the necessary files:

gulp.task('watch', ['build'], function() {
    return watch([
        'blocks/**/*.styl',
        'blocks/**/*.js',
        'blocks/**/*.deps.js'
    ], function () {
        return gulp.start('build');
    });
});

When I change `.js` or `.styl` everything rebuilds correctly. `build` depends on tasks: `deps` and `css`. I do as recommended in gulp-bem-stub . But if I change the `.deps.js` file, excluding some block from the assembly, it still comes. If I make a syntax error there, the console won't crash, because apparently the dependencies are not rescanned. Although there is a clear challenge. If I manually write `gulp build`, then everything works. If the "caretaker" does this instead of me, then the effect that we would like is not obtained.
Already got to this:
var bem, deps, levels = [
    'blocks/common',
    'blocks/desktop',
    'bundles'
];
gulp.task('deps', function (done) {
    delete require.cache[require.resolve('gulp-bem')];
    bem = require('gulp-bem');
    deps = bem(levels, {
        elem: '__',
        mod: '--'
    }).deps('bundles/profile');
    
    return done();
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question