S
S
Sergey2018-04-23 22:16:08
JavaScript
Sergey, 2018-04-23 22:16:08

Running Gulp task?

I can’t figure out how to update index.min.jswhen changes are made in script.js, but do not touch those files in which there were no changes. There is a task

gulp.task('scripts', function(){
  return gulp.src([
    'src/assets/libs/jquery/dist/jquery.min.js',
    'src/assets/js/script.js'
  ])
  .pipe(concat('index.min.js'))
  .pipe(uglify())
  .pipe(gulp.dest('src/assets/js'));	
});

gulp.task('watch', function() {
  gulp.watch('src/assets/css/**/*.*', gulp.series('styles')).on('unlink', 
    function(filepath) {
      remember.forget('styles', path.resolve(filepath));
  });
  gulp.watch('src/**/*.*', gulp.series('assets'));
});

If I add to the watcher, by analogy with styles, the line
gulp.task('watch', function() {
  gulp.watch('src/assets/css/**/*.*', gulp.series('styles')).on('unlink', 
    function(filepath) {
      remember.forget('styles', path.resolve(filepath));
  });
    gulp.watch('src/assets/js/**/*.*', gulp.series('scripts')).on('unlink', 
    function(filepath) {
      remember.forget('scripts', path.resolve(filepath));
  });
  gulp.watch('src/**/*.*', gulp.series('assets'));
});

Then the scripts are updated after Второйthe browser is restarted and the task scriptsandassets
gulp.task('assets', function() {
  return gulp.src(['src/**'], {since: gulp.lastRun('assets')})
    .pipe(newer('dist'))
    .pipe(gulp.dest('dist'));
});

Please tell me, I'm confused)

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