vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
319 stars 75 forks source link

feature request: supporting custom urlToRequire function #61

Open egoist opened 5 years ago

egoist commented 5 years ago

Allow transformAssetUrls to be used like this:

transformAssetUrls: {
  'optimize-img': {
     src: value => `require('!optimize-img-loader!${value}')`
  }
}
<template>
  <optimize-img src="./foo.png" />
</template>

I can create a PR if you think it's useful.

znck commented 5 years ago

This would be a good improvement. PR much appreciated.

I feel it would be better to just transform the path and leave wrapping in require() on the compiler.

transformAssetUrls: {
  'optimize-img': {
     src: value => `'!optimize-img-loader!${value}'` // transform the path.
  }
}