Closed franciscolourenco closed 5 years ago
https://cli.vuejs.org/guide/css.html#referencing-assets
All compiled CSS are processed by css-loader, which parses
url()
and resolves them as module requests. This means you can refer to assets using relative paths based on the local file structure. Note if you want to reference a file inside an npm dependency or via webpack alias, the path must be prefixed with~
to avoid ambiguity. See Static Asset Handling for more details.
So this works:
background-image: url('~@/assets/logo.png');
@sodatea thanks. Maybe it would be worth adding this example to the documentation, because I did read that section, but it was not obvious that ~
would work with @
.
Version
3.5.5
Reproduction link
https://github.com/franciscolourenco/vue-cli-repro-css-at-src-import
Environment info
Steps to reproduce
src
alias@
What is expected?
It works like imports inside javascript
What is actually happening?