Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
What src to specify in an iframe... in a custom element... in a published package?

I have turned a Flutter web app into custom element, which I am publishing as an npm package.

The output of a Flutter web build is a html file (within which some scripts are run), so a quick way to turn this is a custom element is to wrap it in an iframe. The custom element has the general form:

class CustomElement extends HTMLElement {
    constructor() {
        super();
        this.innerHTML = `
            <iframe src="src/flutter_output.html"></iframe>`; 

Running on localhost, no problem.

Published to npm, yes problem.

This is because the src path in the iframe is relative to the home dir of the users index.html, so if the user has installed the package locally, the src should be something like "./node_modules/@package/flutter_output.html" (hard-coding where the package file will be feels dangerous). Or if they are using unpkg, then presumably the src would link back to unpkg, e.g. unpkg.com/package/flutter_output.html (and this seems wasteful).

So the question is what src do I use in the iframe? Or is there another solution to this issue? I am new to web dev, so could quite easily have overlooked something.

A possible solution could be to lose the iframe and html entirely, by converting the flutter_output.html to javascript. Although this could be very painful.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda