I
I
Ilya Pirozhok2016-09-01 12:10:41
JavaScript
Ilya Pirozhok, 2016-09-01 12:10:41

Browsersync not updating php and js, why?

Only styles are updated. What is the problem? Here is gulpile.js code

var gulp = require('gulp');
var cssmin = require('gulp-cssmin');
var sass = require('gulp-sass');
var rigger = require('gulp-rigger');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var connectPHP = require('gulp-connect-php');
var reload = browserSync.reload;
var url = 'das-elite.loc'

gulp.task('default', ['browser-sync','sass-dev', 'dev-watch']);

gulp.task('browser-sync', ['php-reload'], function() {
    browserSync.init({
        proxy: url
    });
});

gulp.task('dev-watch', function() {
  gulp.watch('./src/sass/**/*.scss', ['sass-dev'])
  gulp.watch(url+'/**/*.php', ['php'])
  gulp.watch(url+'/**/*.js', [reload]);
})

gulp.task('sass-dev', function() {
  return gulp.src('./src/sass/main.scss')
  .pipe(sass().on('error', sass.logError))
  .pipe(autoprefixer({browsers: ['last 15 versions'],cascade: false}))
  .pipe(cssmin())
  .pipe(gulp.dest('../web/css'))
  .pipe(reload({stream: true}))
})

gulp.task('php', function() {
  return gulp.src(url+'/**/*.php')
  .pipe(reload({stream: true}))
})

gulp.task('js', function() {
  return gulp.src(url+'/**/*.js')
  .pipe(reload({stream: true}))
})

gulp.task('php-reload', function() {
  return connectPHP.server();
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amorphine, 2016-09-02
@amorphine

Very hardcore - update php.
Perhaps a sample from one of our projects will help.

gulp.task('browserSync', function()
{
    browserSync.init(
        {
            files: [
                "assets/dist/**/*.css",
                "assets/dist/**/*.js",
                "assets/templates/index.js",
                "semantic/dist/semantic.min.css",
            ],
            reloadOnRestart: true,
            notify: true,
            open: false,
            socket:
            {
                domain: '(тутачки урл):(порт)'
            }
        });
});

gulp.task('watch', ['browserSync'], function()
{
    gulp.watch("assets/sass/**/*.scss", ['sass-desktop', 'sass-mobile']);
    gulp.watch("assets/templates/**/*.hbs", ['templates']);
    gulp.watch("assets/templates/index.js", ['javascript']);
    gulp.watch("assets/js/**/*.js", ['javascript']);
});

Theoretically, it is possible to implement checking php files, but I have not seen this yet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question