javascript - gulp watch .js file doesn't work -


gulpfile.js

'use strict';  var gulp = require('gulp'); var sass = require('gulp-sass'); var browsersync = require('browser-sync').create(); var reload      = browsersync.reload;  gulp.task('serve')  // static server + watching scss/html files gulp.task('serve', function() {      browsersync.init({         server: "./public"     });      gulp.watch('./public/**/*.html').on('change', reload); // worked     gulp.watch('./public/**/*.js').on('change', reload); // doesn't work });  gulp.task('sass', function () {   return gulp.src('./public/sass/**/*.scss')     .pipe(sass().on('error', sass.logerror))     .pipe(gulp.dest('./public/css'))     .pipe(reload({stream: true})); });  gulp.task('sass:watch', function () {   gulp.watch('./public/sass/**/*.scss', ['sass']) });  gulp.task('default', ['serve','sass', 'sass:watch']); 

with above gulp setup, broswersnyc works fine when make changes html , sass files doesn't work javascript files.

this folder structure:

does have angularjs? because app.js (which within public folder) consists of angularjs controllers.

if move app.js "public/js" folder work fine

gulp.watch('./public/**/*.js').on('change', reload); // doesn't work 

because in pervious snippet you're watching js files in child folders of public dir.

you might use line instead, might work

gulp.watch(['./public/**/*.js', './public/*.js']).on('change', reload); 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -