-
Notifications
You must be signed in to change notification settings - Fork 757
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
Error: browserSync.reload() of 2.6.0 #573
Comments
Getting the same over at https://github.com/roots/sage/blob/49c310b2c653d7f3d33ae0095125c54fc40fd0f0/gulpfile.js#L128 |
because 2.6.0 has a regression ref BrowserSync/browser-sync#573
Getting this error as well. |
Something here I suspect https://github.com/BrowserSync/browser-sync/blob/master/test/specs/api/init.reload.js#L91 |
+1 |
1 similar comment
+1 |
+1 same here |
Fixed in 2.6.1 Although, all you guys on the bleeding edge with 2.6.1 should switch to var bs = require("browser-sync").create();
gulp.task('sass', function() {
return sassStream()
.pipe(gulp.dest(src.css))
.pipe(bs.stream({match: "*.css"}));
}); |
Thank you! It works with 2.6.1. 😆 |
Lol sorry for the spam. Took a while to get the formatting matched up on the changelog. Can you help me migrate the below to the new 2.6.x so I can update the docs? Not really understanding how to use the new .create() syntax. // Save a reference to the `reload` method
var reload = browserSync.reload;
// Compile SASS & auto-inject into browsers
gulp.task('sass', function () {
return gulp.src('scss/styles.scss')
.pipe(sass({includePaths: ['scss']}))
.pipe(gulp.dest('css'))
.pipe(reload({stream:true}));
});
// Watch scss AND html files, doing different things with each.
gulp.task('serve', ['sass'], function () {
// Serve files from the root of this project
browserSync({
server: {
baseDir: "./"
}
});
gulp.watch("scss/*.scss", ['sass']);
gulp.watch("*.html").on("change", browserSync.reload);
}); |
hey @austinpray - going forward we'll be advising to always use // old schoolz
var browserSync = require("browser-sync");
browserSync({
server: "./"
});
// new hotness
var sync = require("browser-sync").create();
sync.init({
server: "./"
}); This is partly to allow multiple instances with different concerns, something like: // Create a BrowserSync instance
var bs = require("browser-sync").create();
var bs2 = require("browser-sync").create();
// Listen to change events on HTML and reload
bs.watch("*.html").on("change", bs.reload);
bs2.watch("*.jade").on("change", bs2.reload);
// Provide a callback to capture ALL events to CSS
// files - then filter for 'change' and reload all
// css files on the page.
bs.watch("css/*.css", function (event, file) {
if (event === "change") {
bs.reload("*.css");
}
});
// Now init the BrowserSync server
bs.init({
server: "./app"
}); Even when not doing crazy shiz like this, it's still better to just call |
I encountered a TypeError when using
browserSync.reload()
in my gulpfile.The task works correctly with
[email protected]
, but it fails in2.6.0
.And when I comment out the line of
.pipe(reload({stream: true}))
, the task is completed.I suppose the new
.reload()
method has an issue.My gulp task:
Whole gulpfile.js is here.
Error message:
The text was updated successfully, but these errors were encountered: