0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vue-CLI 3 背景画像の「@」が変換されない

Last updated at Posted at 2019-06-07

Webpack 3~4 の話

@はsrc/のエイリアスになっている、

vue.config.js デフォルトはそういう設定になっているので使ってると、
たまに変換されない時があって困る。

select {
        background-image: url('@/assets/img/image.svg');
        }

↓できた

select {
        background-image: url('~@/assets/img/image.svg');
        }

In order to resolve an alias (@), as you are using, it is mandatory webpack handles the request as a module request. Using the prefix ~ enforces webpack treat the request as a module request, similar to require('some-module/image.svg').

あなたのような使い方のエイリアス(@)を解決するためには、
webpackがリクエストをモジュールリクエストとして扱う必要があります。

接頭辞 ~ を使用するとwebpackはrequire
('some-module / image.svg')のように
リクエストをモジュールリクエストとして扱います。

古い時代のハックです。

参考リンク:
https://stackoverflow.com/questions/51812496/vue-cli-3-use-background-image-in-style-tag

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?