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
gfscott
wants to merge
2
commits into
main
Choose a base branch
from
gfscott-public-assets-readmes
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Use the `/app/assets` folder to store static files that **should be processed at build time**. | ||
|
||
Files in `/app/assets`: | ||
- Get uploaded to the Shopify CDN on deployment | ||
- `/app/assets/logo.png` → `cdn.shopify.com/0000/0000/0000/assets/logo-p7f8c0gh.png` | ||
- Can be imported in your app files | ||
- Example: `import logo from '~/app/assets/logo.png'` | ||
- Get processed by Hydrogen's build tools | ||
- File names are likely to be hashed (`/app/assets/logo.svg` -> `/dist/assets/logo-p7f8c0gh.svg`) | ||
- SVG images may be inlined | ||
- CSS or JavaScript files may be chunked, uglified, and/or minified |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Use the `/public` folder to store static files that **shouldn't be processed at build time**. | ||
|
||
Files in `/public`: | ||
- Get uploaded to the Shopify CDN on deployment | ||
- `/public/image.png` → `cdn.shopify.com/0000/0000/0000/image.png` | ||
- Can't be imported in your app files (see `/app/assets` instead) | ||
- Aren't processed by Hydrogen's build tools |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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?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.
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?
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.
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.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.
That's the worker domain. I guess it doesn't proxy
.md
files to the CDN 🤔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.
@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.
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.
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.
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.
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?
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 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.
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.
Oh yeah, this is not urgent at all