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

176
Visualizações
Failed to load the image in vue component published to codeArtifact

I made vue component to display just an image.

I've done npm build:lib and npm publish it. However, it couldn't load the image, but the mark like this picture

Also, I found that path inside src attribute was not identical with node_modules/icon-test/dist folder's structure in the project where I installed the component.

<img data-v-43101371="" alt="cat" src="http://localhost:8081/js/73b12abfb4c55c5d8c687fd31d469762.jpg">

I've been stuck with this issue several days. I'd appreciate if anyone provide some information.

My component files are below:

component file structure

components/CatImage.vue:

<template>
  <div class="hello">
    <img alt="cat" :src="showCat" />
  </div>
</template>

<script lang="ts">
import { Vue } from "vue-property-decorator";

export default class CatImage extends Vue {
  private showCat: string = require("@/assets/img/cat.jpg");
}
</script>

views/Home.vue

<template>
  <div class="home">
    <CatImage />
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import CatImage from "@/components/CatImage.vue";

@Component({
  components: {
    CatImage,
  },
})
export default class Home extends Vue {}
</script>

vue.config.js

module.exports = {
  chainWebpack: (config) => {
    config.module
      .rule("images")
      .test(/\.(png|jpg|jpe?g|gif|webp)(\?.*)?$/)
      .use("file-loader")
      .loader("file-loader")
      .options({
        name: "[name].[ext]",
        outputPath: "assets/img/",
      })
      .end();
    config.module.rule("images").use("url-loader").loader("file-loader");
  },
};

about 4 years ago · Juan Pablo Isaza
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