feat(compiler-sfc): support includeAbsolute in transformAssetUrl

This commit is contained in:
Evan You 2022-06-16 22:59:14 +08:00
parent 96cd1d03fd
commit 8f5817a7c9
2 changed files with 10 additions and 1 deletions

View File

@ -13,6 +13,10 @@ export interface TransformAssetUrlsOptions {
* imports, they will be directly rewritten to absolute urls.
*/
base?: string
/**
* If true, also processes absolute urls.
*/
includeAbsolute?: boolean
}
const defaultOptions: AssetURLOptions = {

View File

@ -31,7 +31,12 @@ export function urlToRequire(
return returnValue
}
if (firstChar === '.' || firstChar === '~' || firstChar === '@') {
if (
transformAssetUrlsOption.includeAbsolute ||
firstChar === '.' ||
firstChar === '~' ||
firstChar === '@'
) {
if (!uriParts.hash) {
return `require("${url}")`
} else {