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.

Cannot disable browser-sync injection into iframe

See original GitHub issue

Ultimately, I am trying to prevent browser-sync (v2.5.2) from injecting into an iframe with a src of local content.

I’ve tried to disabled it completely with:

    gulp.task('browser-sync', function() {
      browserSync({
        snippetOptions: {
          rule: {
              match: /xxx/
          }
        },
        server: {
          baseDir: [__dirname] + '/_build/',
        }
      });
    });

I’ve also tried ignoring all files:

    gulp.task('browser-sync', function() {
      browserSync({
        snippetOptions: {
          ignorePaths: "*.html"
        },
        server: {
          baseDir: [__dirname] + '/_build/',
        }
      });
    });

But these don’t work (also tried blacklist) and the snippet is injected to both the parent and iframe. Am I missing something?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tomgenonicommented, May 20, 2015

Thank you @shakyShane. I can confirm this works. I’ve updated my example repo to provide a working version: https://github.com/tomgenoni/browser-sync-block-iframe-example

0reactions
shakyShanecommented, May 20, 2015

@tomgenoni - there was an error in your original gulpfile. snippetOptions is a separate option, but you had it nested under the server property.

Either way, in your example, with the latest update (2.7.2), this will work as expected.

gulp.task('browser-sync', function () {
    browserSync({
        server: {
            baseDir: [__dirname] + '/dist/'
        },
        snippetOptions: {
            blacklist: ["/iframe/index.html"]
        }
    });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot disable browser-sync injection into iframe #553 - GitHub
Ultimately, I am trying to prevent browser-sync (v2.5.2) from injecting into an iframe with a src of local content. I've tried to disabled...
Read more >
How to blacklist, ignorePaths on iframe content using browser ...
I am using browser-sync to develop ui for a site, and the browser-sync snippet is being injected into an iframe on the page, ......
Read more >
Browsersync options
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >
Top 18 Most Common AngularJS Developer Mistakes - Toptal
Common Mistake #1: Accessing The Scope Through The DOM. There are a few optimization tweaks recommended for production. One of them is disabling...
Read more >
Cross-Browser support with Cross-Origin isolation
If you load a document inside an iframe , its context is not considered secure if an ancestor was not served over HTTPS....
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