-
Notifications
You must be signed in to change notification settings - Fork 756
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
Doesn't reload a browser #392
Comments
Have you checked https://github.com/shakyShane/browser-sync#requirements |
The snippet is injected successfully. Why? What is wrong? Changed gulpfile.js: browserSync({
proxy: "localhost:8000",
open: false
});
gulp.task('dev', function() {
nodemon(nodemonConf)
.on('restart', function () {
browserSync.reload();
console.log('== Restarted! ==');
});
});
// gulp.task('default', ["browser-sync", "dev"]);
gulp.task('default', ["dev"]); |
Did you had any luck with that cause it looks like I have similar issue. I am running browser-sync@2.7.6. I am getting "Reloading browsers ..." log message but the browser does not reload. It can happen that it reloads only once (the first time). |
I am getting the same issue as @bravewick with same version. log message says "Reloading Browsers..." but doesn't reload the page. When I refresh manually I can see the changes. If I run Browserync via command-line it works though... |
I figured it out. I was responding with just 200 (serverside) and that means no body tag for browser-sync to inject the script tag. @rjaguilar maybe you have similar issue ? |
I have this issue too, I even asked on Stackoverflow, but nothing. I'm on Windows 8.1 Pro. |
I was facing the same issue and managed to temporarily settle it with providing a delay to calling Browsersync stuff on nodemon's |
@evenfrost I had a similar issue and ended up by removing |
@eric-dango Doesn't seem to work for me. Would you mind sharing your config to see if there are any differences? |
@evenfrost Sorry. I still have this issue intermittently reproducible after I made my comment. Still need to put a delay on that. Please ignore me. |
Just set BrowserSync's reloadDelay property to some number that works for you. Below is my setup (using Gulp 4.0). 'use strict';
var gulp = require('gulp'),
sync = require('browser-sync').create(),
nodemon = require('gulp-nodemon');
gulp.task('default', gulp.parallel(taskNodemon, taskSync));
function taskSync() {
sync.init(null, {
proxy: "http://localhost:3000",
port: 4000,
files: ["public/**/*.*"],
browser: "google chrome",
reloadDelay: 1000,
});
}
function taskNodemon() {
return nodemon({
script: 'index.js'
}).on('restart', function() {
sync.reload();
});
} |
Thanks..much cleaner. |
I had the same issue and adding a |
+1 for |
Just noticed something: I inserted a class name to html tag and the Browsersync script didn't get inserted. So avoid altering html tag. |
I'm experiencing this using brunch and the brunch plugin. The JS works and I even get an error when killing the brunch server, but it never, ever reloads or even recompiles at all. |
Without it html reload doesn't kick off properly BrowserSync/browser-sync#392
reloadDelay didn't work for me. What seems to do the trick is doing both a task reload and an event based reload at the same time (basically use both the methods in the docs), like this:
|
+1 for reloadDelay, thanks! |
check if your page has a body tag because browser-sync works only with files having body tag |
@ashishagaikwad For me the problem was that in my html file , there was a commented body tag above my actual body tag. Browser-sync injected the script tag after the commented body tag which made it render as commented. |
I had a similar problem. My problem was I had nodemon restarting every time I saved a js file, including those in /source, which trigger |
@ashishagaikwad It's the right point which really puzzle me all day! But I wonder browser-sync should give some kind warnings |
Thanks @Dizzzy ! I've been struggling with browserSync issues for weeks and decided to finally spend 2 or 3 hours yesterday to figure it out. Your approach was the only one that worked. I also used the reloadDebounce option too. |
Thank You @bravewick, this work for me. |
Incredible... I had a --> PAY ATTENTION IF YOU HAVE OTHER "BODY"'S IN THE CODE <-- |
Shouldn't the script tag inject regardless if a body tag is present? I had this in my html file, which wasn't working: <script type="module" src="./dist/multiple.js"></script> and I had to change it to <body>
<script type="module" src="./dist/multiple.js"></script>
</body> after finding my way to this issue. Is there a problem if it is injected regardless of body tag? |
+100000000 for reloadDelay , spent days on this issue. |
My html was missing the body tag! Finally I've found the reason |
I my case I just forgot to write browser-sync "start" so that's why it was not working. Give me a like if it helps. |
The plugin doesn't reload a browser.
In console it says
[BS] Reloading Browsers...
but nothing is reloaded.Neither it works with injected script tag, nor without.
Nodemon works like a charm but not browser-sync.
Here is my gulpfile.js:
I did as tutorial says. Why it doesn't work?
The text was updated successfully, but these errors were encountered: