Browser Sync not injecting/updating styles
See original GitHub issueI’m using a similar gulpfile to the one on the website. I’m just compiling sass and reloading the styles. The site loads just fine at the BS localhost and IP address, works as it should. Sass compiles but styles don’t update on the sites. Any ideas?
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
gulp.task('serve', ['sass'], function() {
browserSync.init({
proxy: "rwr.dev"
});
gulp.watch("sass/*.scss", ['sass']);
gulp.watch("*.php, *.js").on('change', browserSync.reload);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("sass/*.scss")
.pipe(sass())
.pipe(gulp.dest("css"))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);
It’s a wordpress site running in MAMP if that matters. I have gulp and browser-sync setup inside my theme directory.
Issue Analytics
- State:
- Created 8 years ago
- Comments:47 (1 by maintainers)
Top Results From Across the Web
Browser Sync not refreshing after injecting css - Roots Discourse
The problem I'm having is that browser sync is not refreshing once the new css is injected. Browser sync is working as I...
Read more >Browser-sync not injecting CSS for remote site - Stack Overflow
I can't host the site locally for development, so I'd rather tweak the CSS locally and see the changes without having to wait...
Read more >Browsersync options
The UI allows to controls all devices, push sync updates and much more. ... Changes you make will either be injected into the...
Read more >Browsersync not injecting CSS or JS files [#3086572] - Drupal
Browsersync not injecting CSS or JS files ... Dear Community,. I got a problem with the current implementation of browsersync with laravel-mix.
Read more >BrowserSync not refreshing - Laracasts
For some reason I can't get BrowserSync to refresh when I update my files. ... the connection gets initialised so BrowserSync is installed...
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
We just solved this but it was due to a caching issue (we modify the css file names for links and then have an RewriteRule to resolve them)
We simply removed our auto_versioning when in development mode and the issues was immediately resolve. While this is unique to our setup I’m mentioning it here so as to encourage others to consider that caching and their app is setup.
In our case the base.css file was being updated during the gulp-task, but since the browser had a <link> to base.1221534296.css it seems that browser-sync wasn’t able to know what css file to sync.
On El Capitan: Ran:
sudo chown -R $(whoami):admin /usr/local
The reason BS reloads is because its firing off the generated souremaps. To prevent BS from reloading instead of injecting the CSS,browserSync.stream( {match: '**/*.css' } )
is requiredMy Code: