SharePoint Framework debug bookmarklet

This bookmark adds the default development query string for SPFx to the current URL.

?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js

Drag this to your bookmark bar.

function updateQueryStringParameter(uri, key, value) {
  var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');

  var separator = uri.indexOf('?') !== -1 ? '&' : '?';

  if (uri.match(re)) {
    return uri.replace(re, '$1' + key + '=' + value + '$2');
  } else {
    return uri + separator + key + '=' + value;
  }
}

var url = window.location.href;

url = updateQueryStringParameter(url, 'loadSPFX', 'true');
url = updateQueryStringParameter(
  url,
  'debugManifestsFile',
  'https://localhost:4321/temp/manifests.js',
);

window.location.href = url;

Related posts