underfin / vite-plugin-vue2

Vue2 plugin for Vite
620 stars 83 forks source link

Vite `base` option ignored #174

Open meduzen opened 2 years ago

meduzen commented 2 years ago

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.

TheNoim commented 2 years ago

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

lishaobos commented 2 years ago

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 } ........ } `