Problems with Gulp Watch in Linux

1

I have a problem with Gulp watch rather particular. I am working on Linux and I am using Browser-Sync with Gulp, my intention is that when I modify any file of my project I recharge the browser and the devices that I have visualizing automatically. This had already been done but I was working on Windows .

The instruction is simple:

return watch('./**/*.*').on('change', browserSync.reload);

This in Windows works perfect but in Linux it does not. What I found is that he does not even receive me. nor the / at the beginning of the chain. If I put only *.* works fine, but obviously that's not good for me.

Does anyone have any idea how to solve this problem?

Thanks

    
asked by Andrés Luque 07.10.2016 в 16:51
source

2 answers

0

I did a project in Github about Gulp maybe I can help you solve your question. You will find it in Gulpfile.js

link

    
answered by 07.10.2016 в 17:05
0

Assuming you have all your files (JS, CSS, HTML) in a folder src , a simple Gulp task with browser-sync would look like this:

const gulp   = require('gulp');
const bs     = require('browser-sync').create();
const reload = bs.reload;

gulp.task('watch', function() {

  bs.init({
    server: ['src']
  });

  gulp.watch('src/**/*.*', [reload]);
});

The string% co_of% passed to 'src/**/*.*' in the first argument is a pattern gulp.watch , which denotes that any file ( glob ) and the folder *.* and any sub directory in src ( src/ ) must be included.

Deep down, GulpJS uses the node package /**/ that supports Linux just like Windows, so the glob pattern is compatible with both environments.

    
answered by 13.10.2016 в 05:25