Skip to content

Self-host lookaside CDN images under /public - #3973

Merged
imdreamrunner merged 2 commits into
facebook:mainfrom
imdreamrunner:feat/self-host-lookaside-images
Aug 7, 2026
Merged

imdreamrunner merged 2 commits into
facebook:mainfrom
imdreamrunner:feat/self-host-lookaside-images

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Astryx's demo imagery was streamed from a Meta-internal CDN (lookaside.facebook.com/assets/astryx/*) — invisible to external contributors and unreachable without Meta network access. An outside contributor couldn't see which images exist, couldn't add a new one, and couldn't run the site with real imagery.

This PR self-hosts every one of those images in the repo, downloaded from the internal asset set and committed under apps/docsite/public/. Nothing is deleted; the images simply move from the CDN into the repo.

📄 Asset mapping (every image → original Asset Manager source + 2x asset ids): https://gist.github.com/imdreamrunner/1574db95a724d793e703036ee625e665

Two homes, by consumer

Images land in one of two directories based on who uses them — matching the repo's existing conventions:

Directory Used by Notes
apps/docsite/public/template-assets/ CLI templates (packages/cli/templates/**) The scaffold-stripper keys off this path — see below. template-assets/ is the pre-existing convention.
apps/docsite/public/images/ Docsite chrome only (apps/docsite/src/**) Brand banner, per-theme product photos (matcha/ butter/ stone/ gothic/ y2k/), theme *-picker.png tiles, avatars/. Mirrors the existing neutral/preview-*.png slot convention (per-theme folders avoid preview-watch.png collisions).

What changed

1. Template demo images → self-hosted at /template-assets/

  • Committed the shared template photo/video set under apps/docsite/public/template-assets/.
  • Repointed all 39 CLI template files + Lightbox.doc.mjs from lookaside.facebook.com/assets/astryx/* to root-relative /template-assets/*.
  • Inlined the CDN/NEUTRAL_CDN base-path variables in favor of literal /template-assets/... paths.

2. Scaffold behavior fully preserved — still inlines base64

The CLI's stripTemplateAssetRefs (run on astryx add) still swaps demo image references for a self-contained inline data: URI placeholder — a generated project renders with zero setup / zero network dependency, exactly as before. Only the path segment the regex matches changed (/template-assets/, excluding placeholder.svg). No image is ever copied into a scaffolded project. Test suite 10/10.

3. Docsite chrome → self-hosted at /images/

  • Brand banner, theme previews, theme pickers, and avatars committed under apps/docsite/public/images/ and repointed there (theme showcase, hero, OG/blog metadata). Under /images/ (not the public root) so theme-name folders can't shadow Next.js app routes.

4. Retina variants ready for later

  • Committed @2x variants alongside their 1x siblings wherever the asset set provides a density=2 source. Each @2x is exactly 2× its 1x sibling. Not referenced yet — ready for a future srcset/next/image pass without re-fetching.

5. Guardrail

  • check-demo-media.mjs: image-backed Thumbnail examples must inline a same-origin, samplable data: URI (required by useImageMode's CORS pixel-sampling).

Result: zero lookaside.facebook.com references remain except the README banner (READMEs render on GitHub and need an absolute URL — will switch to https://astryx.atmeta.com/images/Astryx-Banner.png after merge) and a mocked, never-fetched URL in useImageMode.test.ts.

6. Changeset

  • A [chore] changeset is included for the @astryxdesign/cli package (the scaffold-strip path change). The demo video Nature-1.mp4 (8.4 MB) is committed directly as a normal file alongside the images.

Verification

  • stripTemplateAssetRefs tests 10/10; CLI template-integration 10/10; full docsite suite 238/238; core useImageMode 5/5; check:demo-media pass.
  • Docsite (next dev): all self-hosted assets 200, old CDN paths gone.
  • Sandbox (dev:sandbox): template-assets mirror to public/template-assets/ (gitignored), template previews render.

@vercel

vercel Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 7, 2026 12:38am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 15, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Lightbox (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 642 -
Complexity N/A Very High (83) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from bd849ba to bfe3165 Compare July 15, 2026 18:09
@imdreamrunner
imdreamrunner marked this pull request as ready for review July 15, 2026 18:36
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from bfe3165 to 52e158d Compare July 15, 2026 23:43
@imdreamrunner imdreamrunner changed the title Self-host lookaside CDN images under /public [DO_NOT_MERGE] Self-host lookaside CDN images under /public Jul 15, 2026
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 52e158d to ac306eb Compare July 15, 2026 23:54
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from ac306eb to 0319c7d Compare July 16, 2026 05:05
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 0319c7d to b4d9b87 Compare July 16, 2026 06:25
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from b4d9b87 to 27e6e88 Compare July 16, 2026 16:00
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 453cb79 to aab3bcc Compare July 17, 2026 16:55
Comment thread apps/docsite/src/__tests__/data-extraction.test.ts
@@ -10,7 +10,7 @@ export default function AspectRatioWidescreen() {
<Center width={600}>
<AspectRatio ratio={16 / 9} fit="cover">
<img
src="https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png"
src="/template-assets/light-scene-horizontal-1.png"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for these CLI templates especially we might want absolute URLs. Hmm if we're done with the internal docsite package updates you can try testing by landing this then updating to the canary version. May need to wait for security clearance though (check with Gerard on how long that takes)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By absolute URL, are you referring to the full URL with domain https://astryx.atmeta.com/? yea i figured out we need that for the internal docsite though i am wondering if it would be better if we keep that URL replacing logic in the internal app itself?

@cixzhang

Copy link
Copy Markdown
Contributor

I agree with updating this. We should make sure the CLI templates can still display correctly on the internal docsite. That might mean we need absolute URLs to guarantee we're fetching from the docsite CDN

@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from aab3bcc to 1e6d26d Compare August 3, 2026 18:02
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 1e6d26d to 5048c85 Compare August 3, 2026 23:47
@imdreamrunner imdreamrunner changed the title [DO_NOT_MERGE] Self-host lookaside CDN images under /public Self-host lookaside CDN images under /public Aug 4, 2026
@Daniel15

Daniel15 commented Aug 4, 2026

Copy link
Copy Markdown
Member

This PR adds @2x variants for some images, but doesn't seem to use them? You'd need to do something like this to actually use them:

<img 
  alt="My cool picture"
  srcset="/template-assets/whatever.png 1x, /template-assets/whatever@2x.png 2x"
  src="/template-assets/whatever.png"
/>

(the src is only a fallback for browsers that don't support srcset)

github-actions Bot added a commit that referenced this pull request Aug 4, 2026
@imdreamrunner
imdreamrunner requested a review from cixzhang August 5, 2026 03:06
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 5048c85 to 82e8e8b Compare August 6, 2026 17:57
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deployment failed for project astryx with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

Template demo imagery and docsite chrome images were streamed from the
internal lookaside.facebook.com CDN — invisible to external contributors
and unreachable without Meta network access. Self-host them in the repo:

- Template demo images -> apps/docsite/public/template-assets/, referenced
  by root-relative /template-assets/* paths. stripTemplateAssetRefs still
  swaps these for the inline data: URI placeholder on scaffold (zero-setup,
  no network dependency; no image is ever copied into a scaffolded project).
- Docsite chrome (brand banner, per-theme product photos, theme pickers,
  avatars) -> apps/docsite/public/images/.
- @2x retina variants committed alongside 1x siblings where a retina master
  exists in Asset Manager. Nature-1.mp4 committed as a normal file.
- check-demo-media guard broadened to ban any remote http(s) in Thumbnail
  examples. README banner kept on lookaside until the PR merges.
@imdreamrunner
imdreamrunner force-pushed the feat/self-host-lookaside-images branch from 82e8e8b to d7ef690 Compare August 6, 2026 21:38
github-actions Bot added a commit that referenced this pull request Aug 7, 2026
@imdreamrunner
imdreamrunner merged commit b68ee61 into facebook:main Aug 7, 2026
19 checks passed

This branch was successfully deployed

1 active deployment
Preview — b98fd227 Deployed Aug 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants