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

89
Visualizações
Add Vue.js script tag to website which already uses Vue

I have a widget written in Vue.js v2 which gets installed on 3rd party websites. It is something similar to those chat widgets which you come across on many websites.

It is created with vue-cli and is bundled into a single JS file. This allows 3rd party websites to install the widget via a single script tag pointing to the JS file, for example:

<script async src="https://www.example.com/js/widget.js"></script>

Here is the section of my vue.config.js which bundles the app into a single JS file:

  configureWebpack: {
    output: {
      filename: "js/widget.js",
    },
    optimization: {
      splitChunks: false,
    },
  },
  css: {
    extract: false,
  },

Everything works correctly when installed on regular HTML websites or single page apps. The issue I'm noticing is when a 3rd party adds my widget onto a website which already has Vue.js added via a script tag, for example:

<script src="https://unpkg.com/vue@2.6.12/dist/vue.min.js"></script>
<script type="text/javascript">
    new Vue({
        ...
    })
</script>

So the 3rd party website is simply adding Vue to a single html page to do something. But on those pages, my widget breaks.

The error I get is:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'mutate')

I don't believe the exact error message is the important part. The underlying issue lies in installing a widget written in Vue onto an html page which also happens to have Vue added via a script tag.

Is it possible to have both on the same page? I don't have any control over where the widget is installed.

almost 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