question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack resolve image

See original GitHub issue

I am trying to add image to the src attribute, but it’s not working… How does avatar resolve images? I am working with Nuxt.js which uses Webpack to resolve images.

Does not work <avatar src="@/assets/img/profiles/test.png">

works <avatar src="https://eliep.github.io/vue-avatar/static/darth-vader.png">.

If I do this <img src="@/assets/img/profiles/test.png">, the image is displayed.

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
saintplaycommented, Feb 2, 2018

Just in case someone is suffering because of this:

    <avatar
      username="Vader"
      :src="require('~/assets/img/vader.png')"
    />

Using require will do the job!

0reactions
saintplaycommented, Nov 29, 2017

I just checked Nuxt documentation https://nuxtjs.org/guide/assets/ and you can try using the require statement

<template>
  <img src="~/assets/image.png">
</template>

It will be compiled into:

createElement('img', { attrs: { src: require('~/assets/image.png') }})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack resolve images in certain directory - Stack Overflow
To reference the images from /src , I have to currently do this: require("../assets/images/some-image.png");. Is there a way that I can simplify ...
Read more >
Possible to have image paths resolved using ... - GitHub
In my webpack.config.js resolve: { alias: { // Allow friendly reference ... As it stands my images still need relative paths, to reference ......
Read more >
Asset Management - webpack
Now let's try to incorporate some other assets, like images, ... + filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, }; ...
Read more >
[SOLVED] Image problems after upgrading to Webpack 5 ...
The image problems started with having to change ... So, I'm thinking that Webpack is looking at resolve.extensions for how to load the ......
Read more >
image-webpack-loader - npm
image -webpack-loader. Image loader module for webpack. Minify PNG, JPEG, GIF, SVG and WEBP images with imagemin. Issues with the output should ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found