Skip to content
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 Readmes for public and app/assets directories #1934

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gfscott
Copy link
Contributor

@gfscott gfscott commented Apr 1, 2024

We've observed some confusion in the wild about the two directories where Hydrogen projects can keep static assets: /public and /app/assets.

This PR adds a readme to each directory with some contextual detail on what happens to the assets stored there. Very open to edits, fact-checks, etc.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@gfscott gfscott requested a review from a team April 1, 2024 21:41
@gfscott gfscott self-assigned this Apr 1, 2024
@@ -0,0 +1,7 @@
Use the `/public` folder to store static files that **shouldn't be processed at build time**.
Copy link
Contributor

@frandiox frandiox Apr 2, 2024

Choose a reason for hiding this comment

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

This file here will be publicly available in domain.com/readme.md if they don't remove it manually. Perhaps we should inform about assets in the root template readme instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, I wondered about that. Could move it out for sure, although I think having it in context has some value. Is there some way to configure an ignore rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just testing this out, and of course the build process does produce dist/client/readme.md. But it throws a 404 in Oxygen: https://01htfeq3ddq1kvwp4adw76d3tf-bdc62392032d96aafe24.myshopify.dev/readme.md — wondering if the CDN just ignores certain file types by default or if there's something else going on.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the worker domain. I guess it doesn't proxy .md files to the CDN 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

@jgodson confirmed: https://github.com/Shopify/oxygen-workers/blob/fc213b66075fdd59a74954317fa77b4794d91a64/packages/routing-worker/src/assets.ts#L23-L44

@gfscott is the desire to give this folder context on Github with the readme file? Or also to give context inside vscode after you've scaffolded a new project? If it's just Github, we could update the CLI to not copy it over on new projects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nm, apparently there's a time in the future where this will change, and our proxy logic will not filter assets like this, so then this file would start to show up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is the desire to give this folder context on Github with the readme file? Or also to give context inside vscode after you've scaffolded a new project?

More the latter. Why ask them to google it or pore over the docs when we could just say what the folder is, right in context? Seems to me like the canonical role of a readme file.

That said, example.com/readme.md is not a desirable outcome 😅

Is there some exclude/ignore list we can give to Vite at build time?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd need to update the deploy command to exclude them somehow. Maybe an ignore file. I don't think we will have time to do this for the release this week.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, this is not urgent at all

Co-authored-by: Fran Dios <frankdiox@gmail.com>
Copy link
Contributor

shopify bot commented Apr 2, 2024

Oxygen deployed a preview of your gfscott-public-assets-readmes branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM
vite ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment April 2, 2024 1:07 PM

Learn more about Hydrogen's GitHub integration.

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

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

I don't think we should ship things to the public directory at the moment, unless we have mechanism to prevent them from getting deployed or copied in the starter template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants