Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
browserSync seems to reload even though I tell it to stream

Consider the following code:

function styleIt(){
    let dir = "./SomeDir/"+curProject+"/assets/";

    return gulp.src( dir+"scss/**/*.scss" )
    .pipe( sass().on('error', sass.logError))
    .pipe( sass({ 
            errLogToConsole: true
        })
    ).on('error', function(e){console.log(e)} )

    // auto prefixer
    .pipe( autoprefixer({ browsers: ['last 2 versions', 'ie >= 11', 'android >= 4.4', 'ios >= 7'] }) )
    .pipe( gulp.dest( dir+'css/' ) ).on( 'error', function(e){ log(e) } )

    // stream changes to all browsers .stream()
    .pipe( browserSync.stream() );
}
function watchIt(){
    let dir = "SomeDir/"+curProject+'/assets/';

    browserSync.init({
        plugins: ['bs-console-qrcode'],
        open: false,
        proxy: curProjectUrl,
    
        files: [ dir+'/**' ],
        serveStatic: [ dir+"/" ],
        rewriteRules: [
            {
                match: new RegExp('SomeDir/inject.css'),
                fn: function() {
                    return '/css/'+curProject+'.css';
                }
            }
        ],
        snippetOptions: {
            rule: {
                match: /<\/body>/i,
                fn: function (snippet, match) {
                    return '<script type="text/javascript" src="/js/'+curProject+'.js"></script>' + snippet + match;
                }
            }
        }
    });

    const watcher = gulp.watch( "./SomeDir/"+curProject+"/assets/**/*.scss", styleIt);

    watcher.on('change', function( path, stats) {
        console.log(`File ${path} was changed `+stats);
    });
}
exports.watchIt = watchIt;

As you can see there's not a single mention of the .reload but I do .stream.. still browserSync seems intend on refreshing the page instead of streaming the change. And I can for the life of me not figure out why it ignores the stream and reloads instead. Can anyone see what I have missed?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda