Skip to content

Commit

Permalink
fix(transform-require): support ~/ aliases (#927)
Browse files Browse the repository at this point in the history
* 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 c48b6c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/template-compiler/modules/transform-require.js
Expand Up @@ -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})`
}
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/resolve.vue
Expand Up @@ -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.