microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
125 stars 39 forks source link

how to use init options `usePlatformScripts` and `usePlatformStyles` like vss-web-extension-sdk? #30

Open yunsii opened 4 years ago

FlexiGit commented 4 years ago

This sdk doesn't support those options. It is intended to be used in conjunction with the "new" ReactJs based azure-devops-ui.

(Disclaimer: I'm not affiliated with MS and this answer is only based on experimenting)

yunsii commented 4 years ago

Thanks, @FlexiGit . I got it when I know the new sdk more. It works in most case, But some case is not work very well. I encounter a question: how to use Bowtie font or others static resouces?

Here is my temporary solution:

async function loadBowtieFont() {
  const origins = location.ancestorOrigins;
  if (origins.length) {
    const css = `@font-face {
      font-family: 'Bowtie';
      src: url('${origins[0]}/_static/tfs/Dev17.M153.5/_content/Fonts/Icons/bowtie.woff') format('woff');
    }`,
      head = document.head || document.getElementsByTagName('head')[0],
      style = document.createElement('style');

    head.appendChild(style);

    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
  }
}

Maybe CDN is better solution?

FlexiGit commented 4 years ago

Maybe you could have a look at azure-devops-extension-sample. They use webpack to build and package the extension. I employ a similar approach for my extensions.

yunsii commented 4 years ago

I had learned azure-devops-extension-sample. It package static resources into extension, but I think it's overstaffed as common resources.

Moreover, according to https://github.com/microsoft/azure-devops-extension-sdk/issues/17, it's impossible to develop dashboard widget with new sdk. So I decided to develop dashboard widget with old sdk.

htekdev commented 2 years ago

@yunsii checkout my comment over here: https://github.com/microsoft/azure-devops-extension-sdk/issues/22#issuecomment-1133211928

Just opened a PR for the integration between both since it's a reoccurring problem. https://github.com/microsoft/azure-devops-extension-sdk/pull/51