-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browsersync reload browser before running styles #282
Comments
+1 |
Just checking to see if anybody has solved this yet? |
Nope, hasn't been solved. Hence, the v5 is now officially published. |
Can you share your gulpfile please |
Sure -- attached is my gulpfile which I needed to convert to txt so I could upload to git. |
Thanks @jackfearing,
In the browsersync doc they mention use of stream for css and reload for html file changes; Following the documented example here;
Let me know what your output is, and if that's the case I'll create a PR. Cheers |
Unfortunately I still see same issue. Is there something else I could try? Attached is my revised gulp file if that helps... |
Sorry @jackfearing that's frustrating. The stream shouldn't reload the browser but instead just inject the css. If that's not happening maybe try debug logging to get more verbose information. But I found several other similar threads saying might be permissions, etc. Or maybe just instead of stream do a reload to force reload as the inject doesn't seem to work. Some threads to go through and attempt; I saw @JeremyEnglert on one, Jeremy did you have any luck with your issue as it seems similar. Thanks |
Thanks -- for the force reload, are you taking about just loading the browser manually or is there a force reload browser sync snippet? |
Garrett - do you think the issue could be caused by browser caching? |
@jackfearing for switching to reload over stream try switching |
As to browser caching I don't believe the Header tags get injected when using Browsersync but had to say. You can try a manual reload but that defeats the purpose. Other than that updating to latest gulp, browsersync and browser (chrome, etc) might work. But I'm at a loss beyond that sadly |
Not sure if tis is the solution but I did try disabling Chrome's browser cache and the issue goes away. I would probably need a 3rd party with the same issue to verify. If that works I'm wondering if there is a gulp setting and/or plugin that would do the job rather than having to go into each browser and adjusting the setting. Select the “Menu” button in the upper-right corner, then select “More tools” > “Developer tools“. You can also get to this screen by pressing Ctrl + Shift + I for Windows and Linux or Command + Option + I for Mac OS X. |
Thanks @jackfearing so it is a browser caching thing. I read a few things about it being known or looked at by BrowserSync but that was in 2015 so not sure if corrected. Maybe update your version of browsersync? The other thought was in the BrowserSync init where you disabled notify maybe set injectChanges to true; |
That seems to work in Chrome. Maybe the issue is Safari and caching... regardless I think this is a good solution for now. Thanks for all your help! |
Awesome glad to hear you're working. Now we'll just need @ashussen to confirm |
Hi Garret, Jack, Thank you for sparing some time to look at this. But it still doesn't work in my case. I think the problem is BrowserSync try to reload the browser before the styles been compiled.
|
Can you share your Gulpfile @ashussen and I'll see if there's anything unique with yours. Cheers |
@garrett-eclipse No, nothing different with my Gulpfile.js. I just tried it again yesterday with a fresh install from the master branch. I managed to get it working, and doing some improvements for my workflow. My fix is, removing the first reload, and just let
|
Nice @ashussen I'm glad it's working for you now. I'll leave this ticket to @JeremyEnglert to review and see if the master gulpfile.js requires a modification. Cheers |
So @ashussen, basically the css is injecting without refresh but you still have the issue of the page not reloading -- correct? |
One thing you might want to try is adding a reloadDelay to the browserSync.init like so. It seems to work with the 'files' parameter in the function.
|
@jackfearing Yes. My current solution is in these 3 cases:
Works fine for me. Thanks for your suggestion for the delay. I will try the code. Also, I noticed, that the Image minified is buggy as well. If you run browsersync, then paste a new image on |
Can you post your working gulp file so I could compare with mine? |
Hi @jackfearing, Here is gist for my gulpfile.js |
I think the styles not injecting/reloading is due to this outdated format in the styles section;
I suggest replacing with either the new stream call or the reload without stream params; Hope that's of some help |
@garrett-eclipse Thanks for your suggestion, but as I mentioned before. I tried both cases, but no luck on those. |
I was having the same issue. Commenting out `// Browser-Sync watch files and inject changes
});` |
Tagging up on m72 comment above, below is my latest gulp file which seems to do the trick. All the styles get injected rather then having the page reload however if the page / templates are changed, only then does the page reload. `// GULP PACKAGES // GULP VARIABLES // Set local URL if using Browser-Sync // Set path to Foundation files // Select Foundation components, remove components project will not use
}; const ASSETS = { const JSHINT_CONFIG = { // GULP FUNCTIONS
}); // Compile Sass, Autoprefix and minify // Compile Sass (Login), Autoprefix and minify // Optimize images, move into assets directory gulp.task( 'translate', function () { // Browser-Sync watch files and inject changes
}); // Watch files for changes (without Browser-Sync)
}); // Run styles, scripts and foundation-js |
+1 for @m72 's solution - I was experiencing the same behavior as OP, and this fixed it for me. Thank you! |
To resolve the browsersync issues outlined in JeremyEnglert#282 I've removed the styles, scripts and images from the files array as they're being watched separately and the double-watching causes users reloading issues.
Thanks everyone, I've created PR #303 to correct this. As I don't have an instance of this issue can I get some testers/reviewers from this thread to look at it please. |
Thanks everyone! @garrett-eclipse's PR has been merged into the master branch. |
I run
gulp browsersync
.But unexpectedly it reloads the page before running the
styles
script. The most recent changes I made is not applied.I need to either save it twice or reload the browser manually.
How to reload the browser after it compiles the styles?
Here is the log:
The text was updated successfully, but these errors were encountered: