A
A
aksak19882018-03-09 17:32:03
Nginx
aksak1988, 2018-03-09 17:32:03

Gulp.js + Browsersync + PHP + Ubuntu - why doesn't it work?

Hi all!
Installed the LEMP stack (nginx server) on Ubuntu, set it up, and it works.
Then I decided to install Browsersync and run it through Gulp.js, tracking changes in PHP files.
Does not track changes in PHP files. How to fix it?
Here is the contents of the gulpfile.js file:

var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var paths = {
   php:['./**/*.php']
};
 
gulp.task('php', function(){
  return gulp.src(paths.php)
  .pipe(reload({stream:true}));
});
 
gulp.task('browserSync', function() {
  browserSync({
    proxy: 'project.org'
  });
});
 
gulp.task('watch', function() {
   gulp.watch(paths.php, ['php']);
});
 
gulp.task('default', ['watch', 'browserSync']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aksak1988, 2018-03-15
@aksak1988

The solution was to simply add after the body tag

<script>
  //<![CDATA[
      document.write("<script async src='/browser-sync/browser-sync-client.js?v=2.17.5'><\/script>".replace("HOST", location.hostname));
  //]]>
  </script>

There are also alternative options:
https://browsersync.io/docs#requirements
https://browsersync.io/docs/options/#option-snippe...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question