Skip to content
Permalink
Browse files
fix(transform-require): support ~/ aliases (#927)
* fix(transform-require): support ~/ aliases

* test: add tests for ~/ aliases
  • Loading branch information
pi0 authored and yyx990803 committed Aug 3, 2017
1 parent 1172384 commit c48b6c7d708fb2b086dde681f0e895d763ad0ee9
Showing with 4 additions and 1 deletion.
  1. +2 −1 lib/template-compiler/modules/transform-require.js
  2. +2 −0 test/fixtures/resolve.vue
@@ -40,7 +40,8 @@ function rewrite (attr, name) {
var firstChar = value.charAt(1)
if (firstChar === '.' || firstChar === '~') {
if (firstChar === '~') {
value = '"' + value.slice(2)
var secondChar = value.charAt(2)
value = '"' + value.slice(secondChar === '/' ? 3 : 2)
}
attr.value = `require(${value})`
}
@@ -2,10 +2,12 @@
<div>
<img src="./logo.png">
<img src="~fixtures/logo.png">
<img src="~/fixtures/logo.png">
</div>
</template>

<style>
html { background-image: url(./logo.png); }
body { background-image: url(~fixtures/logo.png); }
body { background-image: url(~/fixtures/logo.png); }
</style>

0 comments on commit c48b6c7

Please sign in to comment.