Closed bluwy closed 1 year ago
Works with existing Astro features, like content collections and
astro:assets
images.
Is the intention that this will also work with Astro generated <picture>
tags? Currently these come from the <Picture>
element in the @astrojs/image
integration. However, I'm unclear on how astro:assets
relates to <picture>
tags since astro:assets
are new and experimental.
Good point. Since astro:assets
is still experimental, let's make sure @astro/image
would work with this proposal too. <picture>
should also work. Will update the issue.
Probably okay to leave as-is given the good convo already kicked off, but for future proposals: we discussed reducing the effort on Stage 1/2 and moving away from including a specific solution in the OP to just including background/goals/non-goals. Solution ideas and discussion can go in a comment below (optional) at anytime, or just the RFC.
Two examples:
This is released, thank you @bluwy !
Body
Summary
Provide an option to specify a CDN URL for static assets to serve from in production.
Background & Motivation
Large traffic sites often have CDN servers that are optimized to serve assets only. For example, a site served from
https://astro.build
would reference all it's assets fromhttps://cdn.astro.build
.A CDN URL would also allow assets from multiple sites to be deployed to the same CDN server to share the performance, where they can be separated by URL subpaths.
There are also prior art from other frameworks that users want in Astro too:
Goals
import.meta.env.*
) to prepend links manually.astro:assets
images, and@astrojs/image
.Non-Goals
<link href>
or<img src>
etc.public
directory.Example
Astro config:
Generated HTML example:
Details and behaviours:
build.assets
option of_astro
directory, the user will copy all the files from thedist/_astro
directory to thehttps://cdn.example.com
server.base
option, becausebase
is the serving base of the user-facing site URL, e.g.https://example.com/foo/
. (similar to prior art)https://cdn.example.com/project-a
, and Astro would include it in the built URL.More prior art research
assetPrefix
.next/static/
ashttps://cdn.com/_next/static/
app.cdnURL
.output/public/_nuxt/
ashttps://cdn.com/_nuxt/
path.assets
.svelte-kit/output/client/_app/
ashttps://cdn.com/_app/
*Upload path may depend on deployment target / adapter