vite-plugin-vue2 icon indicating copy to clipboard operation
vite-plugin-vue2 copied to clipboard

Vite `base` option ignored

Open meduzen opened this issue 2 years ago • 2 comments

When providing the base option to Vite config, it is ignored by vite-plugin-vue2, the assets referenced in <template> end up having a wrong path, because the base path isn’t prepended.

I created a minimal reproduction repository containing the exact same app written in Vue 2 and Vue 3, with all the details.

Let me know if it’s enough to help.

meduzen avatar Feb 16 '22 19:02 meduzen

Took me a while today to find this out. Thanks for the info.

TheNoim avatar Feb 21 '22 10:02 TheNoim

how about this

we can chang this function

` // before export function urlToRequire( url: string, transformAssetUrlsOption: TransformAssetUrlsOptions = {}, ): string { const returnValue = "${url}" if ( isExternalUrl(url) || isDataUrl(url) || isHashUrl(url) || isAbsolute(url) ) return returnValue

// ........ } `

` // after export function urlToRequire( url: string, transformAssetUrlsOption: TransformAssetUrlsOptions = {}, ): string { const returnValue = "${url}" if ( isExternalUrl(url) || isDataUrl(url) || isHashUrl(url) ) return returnValue

if (isAbsolute(url)) { // inject vite.options.base in transformAssetUrlsOption return transformAssetUrlsOption.base + url } ........ } `

lishaobos avatar Aug 23 '22 07:08 lishaobos