V
V
vasIvas2015-07-12 22:56:51
JavaScript
vasIvas, 2015-07-12 22:56:51

How to resolve a plugin conflict?

It all started with the fact that the default watch does not see the files created when gulp is running.
I was advised to use gulp-watch , but with the advent of it, another problem appeared.
If you specify the order of tasks execution with the default watch , then everything works as expected.
But in gulp-watch , the sequence is not executed... and it's not even a sequence, but... Imagine
that one plugin watches js changes and performs some action with it.
And so there is a second plugin that also monitors js and also performs some actions with it.
And so it turns out that using gulp-watchafter the second plug-in is
executed, the first one starts to be executed again. And so the stack falls.
These plugins are gulp-jsbeautifier and gulp-concat .
In general, I found a way out, but compared to the ease obtained when using the default watch , everything is very difficult.
Is there a way out?
And I'm also interested in whether the default watcher does not see the files being created and does anyone know how to fix this?
And gulp-watch is started by calling start , which they want to cut out from gulp ,
which in turn means that it needs to be abandoned. And how then to be?
**UPD:**
As it turned out, you can see the contents of the created gulp file, but only if you click save on the file that was at the time of launch. And it turns out that either gulp or sublime text 3 is mocking me.
If someone had a similar experience, then I will be happy to give any advice.

'use strict';

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

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

gulp.task('concat-js', function(){
  return gulp.src('./src/**/*.js')
       .pipe(concat('www' + '.js'))
       .pipe(gulp.dest('./src-concat/'));
});

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

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

And here is the assembly dropping the stack -
var gulp   = require('gulp');
var watch = require('gulp-watch');

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

gulp.task('concat-js', function(){
  return gulp.src('./src/**/*.js')
       .pipe(concat('www' + '.js'))
       .pipe(gulp.dest('./src-concat/'));
});

var jsbeautifier = require('gulp-jsbeautifier')

gulp.task('jsbeautifier', function(){
  return gulp.src('./src/**/*.js')
         .pipe(jsbeautifier())
         .pipe(gulp.dest('./src/'));
});

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

gulp.task('watch', function(){
  watch('./src/**/*.js', function(){
    gulp.start(['jsbeautifier', 'concat-js']);
  })
});

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Igor Pushkarsky, 2015-07-13
@RainMEN

Hey! The default watch, as it were, seems to be watching for changes in files, and not for their presence. I just stupidly create tasks that copy the files I need that I don't edit, like jquery plugins and the like.

P
pomeo, 2015-07-13
@pomeo

You are trying to use gulp-watch like gulp.watch, your first example should look like this

'use strict';
var gulp   = require('gulp');
var watch  = require('gulp-watch');
var concat = require('gulp-concat');

gulp.task('concat-js', function(){
  return gulp.src('./src/**/*.js')
       .pipe(watch('./src/**/*.js'))
       .pipe(concat('www.js'))
       .pipe(gulp.dest('./src-concat/'));
});

gulp.task('default', ['concat-js']);

K
Konstantin Kitmanov, 2015-07-13
@k12th

Does the default watcher not see the created files for everyone
this is an old bug somewhere almost in the depths of nodejs itself, I thought it was fixed a long time ago.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question