Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

538
Views
How do I reload my JS files using browse-sync with GULP JS?

I created a project with gulp js, installed bootstrap, browse-sync and sass.

My gulpfile.js file looks like this:

var gulp = require('gulp');
var browserSync = require('browser-sync').create();
const sass = require('gulp-sass')(require('sass'));

gulp.task('sass', () => {
  return gulp.src("./sass/*.scss")
    .pipe(sass())
    .pipe(gulp.dest("dist/"))
    .pipe(browserSync.stream());
});

gulp.task('start', gulp.series('sass', function() {
  browserSync.init({
    server: "./"
  });

  gulp.watch("sass/*.scss", gulp.series('sass'));
  gulp.watch("./*.html").on('change', browserSync.reload);
}));

gulp.task('default', gulp.series('start'));

When I use the Ctrl + S command in HTML and SCSS files, my project is saved and browser is reloaded; but I want to do this also for my JS files. Can you help me?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Very similar to the way you are dealing with your css, but you can use other plugins like terser to compress your javascript. Here is my js function which concatenates and minifies my javascript before reloading via browsersync

const concat = require('gulp-concat');
const terser = require('gulp-terser'); 

function js() { 
  return src(['./js/*.js'])
  .pipe(concat('scripts.min.js'))
  .pipe(terser())
  .pipe(dest('js'))
  .pipe(browsersync.stream());
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!