A
A
Agent Gus2018-05-20 18:59:22
JavaScript
Agent Gus, 2018-05-20 18:59:22

NodeJs Browser-Sync + Concat does not concatenate MODIFY file, how to trace error?

I have Browser-Sync, it looks for the file that I changed and combines it with other js files into one file 'scripts.min.js'. I have my own hosting.
The problem is that when I run sudo gulp for the first time, all files are combined into one and everything works fine, but if I change the common.js file, then concat merges all files EXCEPT COMMON.js , I think because there is an error in this file , but I can’t track it in any way or this is not the case. So don’t tell me what to do?
gulpfile.js (shortened)

var gulp          = require('gulp'),
    gutil         = require('gulp-util' ),
    sass          = require('gulp-sass'),
    browsersync   = require('browser-sync'),
    concat        = require('gulp-concat'),
    uglify        = require('gulp-uglify'),
    cleancss      = require('gulp-clean-css'),
    rename        = require('gulp-rename'),
    autoprefixer  = require('gulp-autoprefixer'),
    notify        = require("gulp-notify"),
    rsync         = require('gulp-rsync'),
    imagemin 			= require('gulp-imagemin');

// Scripts concat & minify

gulp.task('js', function() {
  return gulp.src([
    'app/libs/jquery/dist/jquery.min.js',
    'app/libs/slick-1.8.0/slick/slick.min.js',
    'app/libs/jQuery.mmenu/dist/jquery.mmenu.all.js',
    'app/js/common.js', // Always at the end
    ])
  .pipe(concat('scripts.min.js').on("error", notify.onError()))
  //.pipe(uglify()) // Mifify js (opt.)
  .pipe(gulp.dest('app/js'))
  //.pipe(browsersync.reload({ stream: true }))
});

gulp.task('browser-sync', function() {
  browsersync({
    server: {
      baseDir: 'app'
    },
    notify: true,
    open:false,
    //host:"192.168.56.1",
  })
});
gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
  gulp.watch('app/sass/**/*.sass', ['sass']);
  gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['js']);
  gulp.watch('app/*.html', browsersync.reload)
});
gulp.task('default', ['watch']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Agent Gus, 2018-05-20
@yanminibaev

The problem was that through FTP there was too much delay and the file was taken, but it was empty.
Decision:

+ var sleep = require('sleep'),

gulp.task('js', function() {
  sleep.msleep(1500);
  return gulp.src([
    'app/libs/jquery/dist/jquery.min.js',
    'app/libs/jQuery.mmenu/dist/hammer/hammer.js',
    'app/libs/jQuery.mmenu/dist/jquery.mmenu.all.js',
    'app/libs/slick-1.8.0/slick/slick.min.js',
    'app/js/common.js', // Always at the end
    ])
  .pipe(concat('scripts.min.js'))	
  //.pipe(uglify()) // Mifify js (opt.)
  .pipe(gulp.dest('app/js'));

  //.pipe(browserSync.stream())
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question