Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SASS + CSS Injecting is not working since 2.24.0 version #1553

Closed
2 of 10 tasks
Chmylov opened this issue May 3, 2018 · 6 comments
Closed
2 of 10 tasks

SASS + CSS Injecting is not working since 2.24.0 version #1553

Chmylov opened this issue May 3, 2018 · 6 comments

Comments

@Chmylov
Copy link

Chmylov commented May 3, 2018

Issue details

Browsersync detects changes in css but it does not inject the new css since 2.24.0 version. You have to manually refresh the page to see the changes

Steps to reproduce/test case

Just use example on https://browsersync.io/docs/gulp to reproduce this issue.

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

// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {

    browserSync.init({
        server: "./app"
    });

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

// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
    return gulp.src("app/scss/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("app/css"))
        .pipe(browserSync.stream());
});

gulp.task('default', ['serve']);

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.24.2 ]
  • Node [ 10.0.0 ]
  • Npm [ 6.0.0 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

gulp.task('sass', () => {
  gulp
    .src('src/scss/main.scss')
    .pipe(ifElse(isDev, () => sourcemaps.init()))
    .pipe(sass().on('error', sass.logError))
    .pipe(postcss([autoprefixer()]))
    .pipe(ifElse(isDev, () => sourcemaps.write()))
    .pipe(ifElse(!isDev, () => cleanCSS()))
    .pipe(gulp.dest('dist'))
    .pipe(browserSync.stream());
});
@huilang-me
Copy link

Hope to fix it soon.

@preliot
Copy link

preliot commented May 3, 2018

Issue details

I've got the same issue and am unable to fix it. I've tried:

  • different browsers (no effect)
  • complete deinstall of node / npm ( no effect)
  • basic project with basic gulp (no effect)

Browser reloading does work for other things like html changes, but browser syncing (css injection) doesn't. For what i can tell this happens:

  1. Change scss file
  1. Browsersync detects it: 1 file changed (style.css)
  2. Task finished

When i inspect websockets in my chrome browser (dev tools > network > ws) i see this data in the send frame:

42/browser-sync,["file:reload",{"ext":"css","path":"C:\\#server\\test\\gulp-test\\css\\style.css","basename":"style.css","event":"change","type":"inject","log":false}]

This tells me the data is actually send, but nothing happens afterwards. My guess is that browser-sync-client.js?v=2.24.2 fails in inserting this stylsheet and fails silently.

Steps to reproduce/test case

Use example on https://browsersync.io/docs/gulp to reproduce this issue. (same as above from @Chmylov)

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.24.2 ]
  • Node [ 8.11.1 ]
  • Npm [ 5.6.0 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

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

var src = {
scss: 'sass/.scss',
css: 'css',
html: '
.html'
};

gulp.task('serve', ['sass'], function() {

browserSync.init({
    server: "./"
});

gulp.watch(src.scss, ['sass']);
gulp.watch(src.html).on('change', reload);

});

gulp.task('sass', function() {
return gulp.src(src.scss)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(src.css))
.pipe(reload({stream: true}));
});

gulp.task('default', ['serve']);`

@preliot
Copy link

preliot commented May 3, 2018

For everyone who can't wait, workaround. Use http://livereload.com/ and https://www.npmjs.com/package/gulp-livereload . This works lighting fast!

@huilang-me
Copy link

huilang-me commented May 3, 2018

We can simply use the old version to instead.
npm uninstall browser-sync

npm install browser-sync@2.18.12

@shakyShane
Copy link
Contributor

I'll be looking at this today

shakyShane added a commit that referenced this issue May 3, 2018
fix: handle windows-style paths on the client - fixes #1553
@shakyShane
Copy link
Contributor

fixed in browser-sync@2.24.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants