Skip to content

Commit

Permalink
feat(compiler-sfc): support includeAbsolute in transformAssetUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 16, 2022
1 parent 96cd1d0 commit 8f5817a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/compiler-sfc/src/templateCompilerModules/assetUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 6 additions & 1 deletion packages/compiler-sfc/src/templateCompilerModules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f5817a

Please sign in to comment.