0

Im kind of new to this. I have a good grasp on gulp but can't seem to figure out how to have gulp watch my file as prettier changes it. I tried but seem to hit a roadblock.

here's what I have so far. if i run the task on its own it works perfectly but I cant make it watch to any changes on save.

    const gulp = require('gulp');
    const pretty = require('gulp-pretty');

gulp.task('prettify', () =>
  gulp
    .src('src/**/*.js')
    .pipe(
      pretty({
        singleQuote: true,
        trailingComma: 'es5',
      })
    )
    .pipe(gulp.dest('src/'))
);

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

gulp.task('default', ['watch', 'prettify']);
  • Possibly related: https://stackoverflow.com/q/37665845/1531971 (if not, tell us why as an [edit].) –  Dec 14 '18 at 21:13
  • Possible duplicate of [Gulp watch not watching file changes](https://stackoverflow.com/questions/37665845/gulp-watch-not-watching-file-changes) – Ruzihm Dec 14 '18 at 21:15
  • never mind, I figured it out. – JoCebreros Dec 14 '18 at 21:47

0 Answers0