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

[Theme] Fix local asset serve for backward compatibility #4624

Merged
merged 4 commits into from
Oct 17, 2024

Conversation

frandiox
Copy link
Contributor

WHY are these changes introduced?

Fixes #4607

WHAT is this pull request doing?

Makes the /cdn/... pathname prefix optional so that it serves local files from localhost:1234/assets/... directly. This is not used by the CLI itself but some users relied on this for custom integrations. I guess we can keep supporting it for backward compatibility? @karreiro @mgmanzella

Note: this only work for local assets. We are not forwarding this type of request to the CDN for files that are only present in the remote version or that need to be rendered remotely (e.g. assets/file.css.liquid). Should we do that?

How to test your changes?

Check that your local theme files can be accesses in the browser from localhost:1234/assets/...

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@frandiox frandiox requested review from karreiro and a team October 10, 2024 04:08
@frandiox frandiox requested a review from a team as a code owner October 10, 2024 04:08
@frandiox frandiox requested review from jantnovi and amcaplan and removed request for a team October 10, 2024 04:08
Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

Copy link
Contributor

github-actions bot commented Oct 10, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.67% (+0.01% 🔼)
8540/11751
🟡 Branches
69.65% (+0.02% 🔼)
4196/6024
🟡 Functions 71.73% 2207/3077
🟡 Lines
73.01% (+0.01% 🔼)
8084/11073

Test suite run success

1943 tests passing in 876 suites.

Report generated by 🧪jest coverage report action from bd948c5

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, @frandiox! 🔥

--

I guess we can keep supporting it for backward compatibility? @karreiro @mgmanzella

+1 for keeping backward compatibility.

Note: this only work for local assets. We are not forwarding this type of request to the CDN for files that are only present in the remote version or that need to be rendered remotely (e.g. assets/file.css.liquid). Should we do that?

No, I don't think we should do that. I believe our compass in this case should be backward compatibility, and the legacy version just points that kind of asset directly to the store/Shopify domain, so there's no backward compatibility requirement in this space.

--

Thanks again for this PR! I've left only one minor suggestion about theme app extensions 🚀

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @frandiox! LGTM and works as expected for themes and theme app extensions.

@frandiox frandiox added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit fa068c1 Oct 17, 2024
@frandiox frandiox deleted the fd-fix-local-asset-serve branch October 17, 2024 07:47
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.

[Bug]: Theme assets /assets/* returns 404
2 participants