Nuxt.js: Webpack doesn't load images from `assets` if using template literals

Created on 28 Sep 2017  路  4Comments  路  Source: nuxt/nuxt.js

I am trying to use something like this

<div :style="type ? {'background-image': `url('~assets/images/${type}.svg')`, 'background-position': '96% 50%'} : ''"></div>

But Nuxt doesn't resolve this path. GET http://localhost:3333/~assets/images/amex.svg 404 (Not Found)

Then I tried simple

<img :src="`~assets/images/amex.svg`">

But this one doesn't work too, so the issue only when using literals.

Any chance to fix this behavior?

This question is available on Nuxt.js community (#c1568)

Most helpful comment

For future googlers stranded on this issue, the following links will help you out:

All 4 comments

Fix it by using require.

how to fix it ?? how to use require @iamdubx

For future googlers stranded on this issue, the following links will help you out:

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surmon-china picture surmon-china  路  3Comments

msudgh picture msudgh  路  3Comments

jaredreich picture jaredreich  路  3Comments

bimohxh picture bimohxh  路  3Comments

vadimsg picture vadimsg  路  3Comments