V
V
Vitalik Cherny2017-05-24 16:33:35
gulp.js
Vitalik Cherny, 2017-05-24 16:33:35

What does the line "stream: true" do?

What does , more precisely "stream: true". The Browsersync API has pro and , but I don't really understand how it works. In there is a parameter (object) transfer. It turns out an option, but I don’t understand where to read about it..pipe(browserSync.reload({stream:true}));.reload( arg ).stream( opts ).reload({stream:true})

"use strict";

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

gulp.task("sass", function() {
  return gulp.src("app/sass/**/*")
  .pipe(sass())
  .pipe(gulp.dest("app/css"))
  .pipe(browserSync.reload({stream:true}));
});

gulp.task("browser-sync", function() {
  browserSync.init({
    server: {
      baseDir: "app"
    },
    notify: false
  });
});

gulp.task("watch", ["sass", "browser-sync"], function() {
  gulp.watch("app/sass/**/*", ["sass"]);
  gulp.watch("app/*.html", browserSync.reload);
  gulp.watch("app/**/*.js", browserSync.reload);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alvvi, 2017-05-24
@alvvi

I don’t know where this object came from, the documentation for the reload method itself, which can be found in the sources, says the same as in the documentation on the site: https://browsersync.io/docs/api#api-reload

/**
 * The `reload` method will inform all browsers about changed files and will either cause the browser to refresh, or inject the files where possible.
 *
 * @method reload
 * @param {String|Array|Object} [arg] The file or files to be reloaded.
 * @returns {*}
 */

Transferring it there is pointless, maybe it used to make sense, but I could not find documentation on previous versions. PS - a separate method, it has no direct relation to .reload. {stream: true}
.stream( opts )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question