-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add build.assetsPrefix
option for CDN support
#6714
Conversation
🦋 Changeset detectedLatest commit: 168e353 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Left some tiny edits for consideration! 🙌
Co-authored-by: Sarah Rainsberger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like our minor
GH action isn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good to me. What's the expectation of the value from the point of view of the user? It's marked as a string
, but if the user puts "anything_fancy", what's the outcome of the build? Should we do some validation? Should we warn the user?
It would act as a normal prefix so it could be anything. I'm mostly testing values like |
Perfect! Thank you for clarifying! |
@bluwy I think in config.ts we specify |
The idea is that it doesn't necessarily need to be a URL, it can be any string prefix depending on their deployment, so I'm not sure if we need that restriction, unless we want to only support URL for now? |
Ah, no, good point. It could just be a path. In that case I agree, let's leave it as a string for now. |
I think I found an issue with this second type of values: #6844 |
Changes
RFC: withastro/roadmap#545
The changes are honestly
base
->assetsPrefix || base
everywhere for asset links. And judiciously handle/
wherebase
needs to be prepended by/
, andassetsPrefix
doesn't.Testing
Added tests for links, images (experimental and
@astrojs/image
), content collections, and SSR.Manual live testing: https://github.com/bluwy/astro-cdn-test and https://bluwy.github.io/astro-cdn-test/
Docs
Document
import.meta.env.ASSETS_PREFIX
at withastro/docs#2971.Documentation for
build.assetsPrefix
is in this PR's@astro/types.ts