'Module not found: Error: Can't resolve 'assets/img vue.js
I have following structure:
-src
-assets
-css
-img
-js
In my style.css I have this line:
background: url(~assets/img/arrows.png) no-repeat;
And get this error
Module not found: Error: Can't resolve 'assets/img/arrows.png'
what do I do?
I tried to write ./assets/, ../assets/ , ./src/assets still doesn't work
Solution 1:[1]
If you've imported the css file in App.vue or any other .vue file make sure the url is relative to that *.vue file
Solution 2:[2]
This issue can come up in Nuxt.js projects. If you're seeing this issue there, you'll have to either use a tilde (~) with no slash in front of the absolute path or you have to use a tilde and an at sign (@), so either this:
background-image: url('~assets/img/arrows.png');
Or this:
background-image: url('~@/assets/img/arrows.png');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ericgm |
| Solution 2 |
