Skip to content

Commit 8f5817a

Browse files
committed
feat(compiler-sfc): support includeAbsolute in transformAssetUrl
1 parent 96cd1d0 commit 8f5817a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/compiler-sfc/src/templateCompilerModules/assetUrl.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export interface TransformAssetUrlsOptions {
1313
* imports, they will be directly rewritten to absolute urls.
1414
*/
1515
base?: string
16+
/**
17+
* If true, also processes absolute urls.
18+
*/
19+
includeAbsolute?: boolean
1620
}
1721

1822
const defaultOptions: AssetURLOptions = {

packages/compiler-sfc/src/templateCompilerModules/utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export function urlToRequire(
3131
return returnValue
3232
}
3333

34-
if (firstChar === '.' || firstChar === '~' || firstChar === '@') {
34+
if (
35+
transformAssetUrlsOption.includeAbsolute ||
36+
firstChar === '.' ||
37+
firstChar === '~' ||
38+
firstChar === '@'
39+
) {
3540
if (!uriParts.hash) {
3641
return `require("${url}")`
3742
} else {

0 commit comments

Comments
 (0)