BrowserSync / browser-sync

Keep multiple browsers & devices in sync when building websites. https://browsersync.io
https://discord.gg/2d2xUThp
Apache License 2.0
12.14k stars 754 forks source link

[BUG] Breaking change in 2.29 (removed document.write) #2031

Closed pySilver closed 1 year ago

pySilver commented 1 year ago

In some configurations it is required to append browsersync snippet into <head> instead of <body>. We are doing that in environment where <body> is being swapped during internal navigation. It is typical html-over-the-wire approach for webapps.

What we used to do is leveraging this option https://browsersync.io/docs/options#option-snippetOptions

snippetOptions: {
    rule: {
      match: /<\/head>/i,
      fn: function (snippet, match) {
        return snippet + match;
      },
    },
  },

it worked perfectly. But with 2.29 release it appends an inline script that in turn appends client to <body> which seems to be hardcoded.

Proposed resolution: an option where to append snippet and client.

shakyShane commented 1 year ago

Hi! Yeah this is a bug - the intention was only to remove document.write, whilst maintaining support for other options.

Thanks for the report, I'll address it soon :)

shakyShane commented 1 year ago

@pySilver please try browser-sync@2.29.3 and let me know if you have any further issues :)