Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack path aliases for <style></style> in Component.vue files #1113

Closed
yyx990803 opened this issue Jan 6, 2018 · 4 comments
Closed

webpack path aliases for <style></style> in Component.vue files #1113

yyx990803 opened this issue Jan 6, 2018 · 4 comments

Comments

@yyx990803
Copy link
Member

Moved from vuejs/vue#7400

What problem does this feature solve?

Basically today I noticed that webpack aliases work properly for import statements, however not with <style> </style> section of .vue component. Example given: '@': './src' alias works fine with import smth from '@/smth' in <script> </script> section, but when i tried this: <style> .jumbotron { background: url('@/assets/images/welcome.jpg') center / cover; } </style> it failed, I thought it would be great to be able to write code this way, so Component.vue works even if its location changes. That would be super cool. Btw I love Vue, thanks a lot for a great work!

**webpack aliases for .vue <style></style> section

What does the proposed API look like?

<style> .jumbotron { background: url('@/assets/images/welcome.jpg') center / cover; } </style>

@ghost
Copy link

ghost commented Jan 26, 2018

Pulled a request #1139

@yyx990803
Copy link
Member Author

yyx990803 commented Mar 7, 2018

Well... I just realized you can already do that with (prefix the url with ~)

<style>
.jumbotron {
  background: url('~@/assets/images/welcome.jpg') center / cover;
}
</style>

So extra processing in vue-loader is not really necessary.

@mfzl
Copy link

mfzl commented Mar 28, 2018

This does not work when image link is specified in inline style attribute as in vuejs/vue-cli#928

@dobromir-hristov
Copy link

I confirm.
Inline style background images do not work.
Using cli v3.0.0-beta.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants