Repository navigation
Conversation
|
Thanks for the links @andrewharvey Seems to be an ongoing discussion since long time ago, so long, I don't remember the actual date. :) But, this is somewhat ugly imo, especially with ssr, you have to built on top of that workaround, mock the window obj. Or this beauty here #3636 (comment) IMHO its natural to have custom sprites served from the current server, so please allow us to make our lives flexible, even if its dangerous and will break in other contexts, we know what we do (most of the time). |
Styles are intended to be consumed by multiple different platforms, e.g. iOS applications, Android apps, and websites. Out of those, websites are the only one that have the concept of "current server" since they have an origin. Allowing relative URLs to styles means that styles won't work on those platforms anymore. However, there is a much cleaner way to allow relative URLs for your website by providing a transformRequest: (url, resourceType) => {
if (/^local:\/\//.test(url)) {
return { url: new URL(url.substr('local://'.length), location.href).href };
}
}allows you to specify relative sprite URLs like See the documentation for Given that there's no reasonable cross-platform way of adding support for relative URLs, but a JS-specific solution, I'm going to close this PR. Thanks for your contribution! |
|
@kkaefer thanks for your explanation. But your suggestion, to use |
Just want to also add that this solution seems to require configuring a local environment to support HTTPS (http would not work in this case...) |
Launch Checklist
Local urls for sprites like "sprite: /assets/sprites" were not possible due to the implicit requirement of (protocol://). Slightly changed the "urlRe" to ignore missing protocol and the same for formatUrl. Additional tests were added, no breaking changes.