-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-vue): allow overwriting template.transformAssetUrls.includeAbsolute (fix #4836) #6779
Conversation
May I kindly ask this to be reconsidered? The main use case is to allow this option to be configured from plugins specific to server integrations, so the user do not have to worry about it. If adding a configuration option is not viable, is there another way? Better heuristics to set EDIT - I updated the PR to do that. The Vue plugin will include absolute URLs by default, unless |
@innocenzi I added this PR back for discussion. Your idea about automatically detecting the use case is interesting, but I don't know if everyone who sets While we discuss, would you remove the automatic detection logic so we can let users disable this by configuring the Vue plugin? Even if it isn't ideal from the user's POV, at least we are unblocking Vue users. |
…ary" This reverts commit f017465.
Hey @patak-dev, thanks! I reverted the commit with the automatic detection. I'm not sure if this was ideal either, I just wanted to try to move forward. What do you think? Should we expose the configuration option, or should we try a better heuristic? I think exposing the option would be the best - but another idea, more complex though, would be to find a way to let plugins configure other plugins. That'd potentially be a big change though. |
I was thinking we could do this in two stages. Let's first go with Evan's suggestion that doesn't need any new option, and would at least let users configure this through the Vue plugin using |
Ah, yes, my bad. I misunderstood what you said. I reverted all new option changes |
resolve.absoluteUrls
option (fix #4836)
@innocenzi @jessarcher [email protected] includes this PR |
Description
This PR fixes an edge-case of
@vitejs/plugin-vue
where absolute URLs would go through the asset plugin, causing build-time crashes.Additional context
In most cases, that would be the expected behavior, but when integrating with back-end frameworks, it's most likely not because they use a different
public
directory, not handled by Vite.Generally, we don't want assets in there to be versioned, and there is potentially not even the referenced asset at build-time. In either case, this causes build-time errors.
For instance, say we have a
public/logo.svg
and reference it with<img src="/logo.svg" />
. Using a back-end framework, we don't want Vite to process this file. In development, this works fine. But at build-time, we get a Rollup error:This PR fixes that issue by providing a new option,
resolve.absoluteUrls
. The reason behind setting this parameter is because we don't want users to have to specify a big option object themselves:Rather, we want this auto-configured in a plugin. The setting may be useful to other plugins too.
Related:
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).