diff --git a/src/template/utils.ts b/src/template/utils.ts index 483a5b3..f1d9cad 100644 --- a/src/template/utils.ts +++ b/src/template/utils.ts @@ -16,7 +16,12 @@ export function urlToRequire( transformAssetUrlsOption: TransformAssetUrlsOptions = {} ): string { const returnValue = `"${url}"` - if (isExternalUrl(url) || isDataUrl(url) || isHashUrl(url)) { + if ( + isExternalUrl(url) || + isDataUrl(url) || + isHashUrl(url) || + isAbsolute(url) + ) { return returnValue } // same logic as in transform-require.js @@ -61,6 +66,10 @@ export function isDataUrl(url: string): boolean { return dataUrlRE.test(url) } +export function isAbsolute(url: string): boolean { + return url.startsWith('/') +} + /** * vuejs/component-compiler-utils#22 Support uri fragment in transformed require * @param urlString an url as a string