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

[2.x] Update the realtime compiler to only serve source media files #2012

Conversation

caendesilva
Copy link
Member

Abstract

This PR changes the realtime compiler to only serve assets from the media source directory (_media), rather than also checking the site output directory (_site/media).

Motivation

The realtime compiler is designed to emulate how the site will behave when served from a web server. When building the site, files from _media are copied to _site/media. Having the realtime compiler serve files from both locations could lead to inconsistencies and confusion about which version is being served.

While we could use filemtime() to serve the latest version, this would not accurately represent the production environment where only the files in _site/media would be available. Additionally, any file in _site/media would be overwritten by the next build anyway.

This change:

  • Simplifies the asset serving logic
  • Makes the behavior more predictable
  • Better aligns with the documented purpose of the directories
  • More accurately represents the production environment

References

See the documentation about media directories in managing-assets.md:

- The `resources/assets` folder contain **source** files, meaning files that will be compiled into something else.
Here you will find the `app.css` file that bootstraps the TailwindCSS styles. This file is also an excellent place
to add your custom styles. It is also where we import HydeFront. If you compile this file in the base install,
it will output the same file that's already included in Hyde.

- The `_media` folder contains **compiled** (and usually minified) files. When Hyde compiles your static site,
all asset files here will get copied as they are into the `_site/media` folder.

- The `_site/media` folder contains the files that are served to the user.

@caendesilva caendesilva force-pushed the update-realtime-compiler-to-only-serve-source-media-files branch from bf25ff5 to 2176280 Compare November 11, 2024 17:15
@caendesilva caendesilva mentioned this pull request Nov 11, 2024
14 tasks
@caendesilva caendesilva merged commit 3b89ec0 into new-asset-system Nov 11, 2024
8 checks passed
@caendesilva caendesilva deleted the update-realtime-compiler-to-only-serve-source-media-files branch November 11, 2024 17:16
Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (89deb54) to head (2176280).
Report is 2 commits behind head on new-asset-system.

Additional details and impacted files
@@                 Coverage Diff                  @@
##             new-asset-system     #2012   +/-   ##
====================================================
  Coverage              100.00%   100.00%           
  Complexity               1891      1891           
====================================================
  Files                     194       194           
  Lines                    5044      5044           
====================================================
  Hits                     5044      5044           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caendesilva caendesilva mentioned this pull request Nov 14, 2024
87 tasks
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.

1 participant