question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browsersync reloads my site twice

See original GitHub issue
  • Laravel Mix Version: 0.11.3
  • Node Version: 7.9.0
  • NPM Version: 4.2.0
  • OS: Windows 10

Description:

Whenever I use mix.browserSync() my browser gets refreshed twice. Also, If I make a change on my Sass, changes don’t get injected; the browser reloads twice no matter what.

Steps To Reproduce:

This is my webpack.mix.js:

const { mix } = require('laravel-mix');

mix.options({ processCssUrls: false });
mix.disableNotifications();
mix.setPublicPath('public');

mix.js('resources/assets/js/app.js', 'js')
   .js('resources/assets/js/realtime/a.js', 'js/realtime')
   .js('resources/assets/js/realtime/b.js', 'js/realtime')
   .js('resources/assets/js/realtime/c.js', 'js/realtime');

mix.scripts([
   'resources/assets/js/vendor/a.js',
   'resources/assets/js/vendor/b.js',
   'resources/assets/js/vendor/c.js',
   'resources/assets/js/vendor/d.js',
   'resources/assets/js/vendor/e.js',
   'resources/assets/js/vendor/f.js',
   'resources/assets/js/vendor/g.js',
   'resources/assets/js/general.js'
], 'public/js/all.js');

mix.less('node_modules/spectre.css/spectre.less', 'css/vendor.css');

mix.sass('resources/assets/sass/main.scss', 'css')
   .sass('resources/assets/sass/realtime/a.scss', 'css/realtime')
   .sass('resources/assets/sass/realtime/b.scss', 'css/realtime')
   .sass('resources/assets/sass/realtime/c.scss', 'css/realtime');

if (mix.config.inProduction) {
    mix.version();
} else {
    mix.browserSync({
        proxy: 'app.dev',
        // I also tried this: files: 'public/**/*'
    });
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jackmcdadecommented, Jun 1, 2017

Ah, I figured out my issue. I was watching the /src/** files instead of the compiled files in /public/{whatever}, so the changes weren’t there until next save. Makes sense. Silly me.

0reactions
dmitryukcommented, Dec 7, 2017

I have found final result should be like

mix.browserSync({
        files: [
            'public/css/*.css',
            'public/js/*.js'
        ]
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Browsersync reloads my site twice · Issue #789 · laravel-mix ...
Whenever I use mix.browserSync() my browser gets refreshed twice. Also, If I make a change on my Sass, changes don't get injected; the...
Read more >
Error You tried to start Browsersync twice - Stack Overflow
I'm trying to set up browsersync within my gulp file but keep getting this error "[error] You tried to start Browsersync twice!".
Read more >
BrowserSync start twice? (gulp) : r/webdev - Reddit
I started to work with BrowserSync (with gulp) and at first everything ... Startup the server in another task and reload it with...
Read more >
Browsersync options
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >
Gulp from Scratch: Browser-Sync Stream changes ... - YouTube
Gulp from Scratch: Browser-Sync Stream changes without Reload ... Designer: http://bit.ly/1X7CrDA :: My Website :: http://www.alecaddd.com/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found