BrowserSync: Sass compilation causing whole page reload
See original GitHub issue- Laravel Mix Version: 1.4.2 (github:jeffreyway/laravel-mix#5aad0dfde5349e284e0876388a6f307547f7c002)
- Node Version (
node -v
): 8.2.1 - NPM Version (
npm -v
): 5.3.0 - OS: macOS Sierra 10.12.6
Description:
When using browserSync, css changes are injected however the page is also reloaded due to the fact that the JS bundle is re-emitted even when the only file that changed was a sass file.
Steps To Reproduce:
webpack.mix.js:
mix
.js('resources/assets/js/main.js', 'public/assets/js/bundle.js')
.extract(['jquery', 'babel-polyfill'])
.autoload({
jquery: ['$', 'jQuery', 'window.jQuery']
})
.sass('resources/assets/sass/style.scss', 'public/assets/css')
.disableNotifications()
.options({
processCssUrls: false
})
.sourceMaps()
.browserSync({
proxy: process.env.APP_URL,
files: [
'app/**/*.php',
'resources/views/**/*.php',
'public/assets/js/**/*.js',
'public/assets/css/**/*.css'
]
})
Run npm run watch
, site is served at localhost:3000, save a sass file and watch the browser refresh rather than just inject the changes.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:18
- Comments:55 (7 by maintainers)
Top Results From Across the Web
BrowserSync reloading the whole page instead of injecting CSS
The problem is that I'm trying to use BrowserSync to reload the page when a .php file changes and to inject my css...
Read more >BrowserSync/Live-Server not updating in Gulp File
Hi TeddyS31,. Gulp will create real-time changes in your live server browser if you run command gulp mdb-go in the background. It will...
Read more >Quick setup for Gulp 4 + Browsersync + Sass - Coder Coder
It works by spinning up a local server and syncing it up to your browser. Then, anytime you make a change in your...
Read more >Sage 10 browsersync issue with reload - Roots Discourse
Is there something to change in the mix config ? And is there a way to make the compiling faster. Apparently If I...
Read more >Gulp for Beginners | CSS-Tricks
If you're crazy enough, you can even build a static site ... We've now managed to compile all Sass files into CSS files...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I finally found a workaround for my case.
I believe the issue is that laravel-mix’s
CustomTasksPlugin
runs all post-build tasks again for every rebuild. In these tasks is where all files built using.babel()
,.scripts()
,.combine()
,.styles()
and even.copy()
are built again.Here is a drop in plugin that ensures these tasks only run at the first build. Subsequent watch builds won’t rebuild all those files again unless you actually modified one of their files. This fixed all my browserSync reload problems.
@karneaud the only workaround is to use
mix.standaloneSass
or just move styles build process out of Webpack