Is it possible to include an image, which is in assets/ foder, in some static .scss file, as a background-image?
I have a _buttons.scss partial and some buttons have an icon, which I'd like to add as a background-image. The icons are located in src/assets/ foder.
App structure:
- src
- assets
some_icon.svg
- components
- scss
_buttons.scss
main.scss
- views
App.vue
main.js
router.js
And in _buttons.scss:
.some-selector {
background-image: url(../assets/some_icon.svg)
/* also tried
background-image: url(./assets/some_icon.svg)
background-image: url(/assets/some_icon.svg)
background-image: url(assets/some_icon.svg)
*/
}
Which returns an error with This relative module was not found.
I know I can simply add those styles (scoped or not) in my component, or in main App.vue, however, I was wondering if this can be achieved without that?
I know also that I can add those icons in my public folder but I would like for the icons to remain in the assets/ folder.
$ vue -V
$ 3.0.0-rc.5
Maybe some custom webpack config?
Thanks
main.scssfile? I'm importing it in themain.jsfile and that relative import works for me.@import 'main.scss'in myApp.vuefile. Is that a good practice to import the .scss file in the main.js?main.scssfromApp.vue. And I can't reproduce the error unless I try a nonexistent URL forbackground-image. Also note that../assets/some_icon.svgis correct. Do you have a repo to look at?main.jsthe.scssfiles. Can you please explain a little bit why it works as an answer and I'll accept it.