Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!