Embed email stylesheet directly in mailer header#2724
Open
mroderick wants to merge 1 commit into
Open
Conversation
mroderick
marked this pull request as ready for review
July 25, 2026 17:37
Eliminate the external `/assets/email.css` dependency for HTML emails by deleting the stylesheet and embedding the full CSS in a `<style>` block inside the shared mailer header partial. This avoids stale/cached CSS and asset-host resolution issues. Premailer inlines the `.soc-btn.*` rules, so the per-element inline `background-color` styles added by the previous fix are no longer needed and have been reverted. Also add a shared RSpec example that verifies every mailer rendering the social footer inlines the five social-button colours, does not reference `/assets/email.css`, and embeds the `<style>` block. Included in all five affected mailer specs. - Delete `app/assets/stylesheets/email.css` - Embed CSS in `app/views/shared_mailers/_header.html.haml` - Revert inline social-link colours from `app/views/shared_mailers/_social.html.haml` - Update `app/assets/images/email/README.md` - Add `spec/support/shared_examples/behaves_like_email_with_social_links.rb` - Include shared example in `spec/mailers/*_invitation_mailer_spec.rb` and `spec/mailers/feedback_request_mailer_spec.rb`
mroderick
force-pushed
the
feature/embed-email-css-in-style-block
branch
from
July 25, 2026 18:15
007d3e3 to
1d3522a
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Emails rely on premailer fetching
/assets/email.cssfrom the configured asset host. Even after #2715 switched the link from a hardcoded path toasset_path("email.css"), the resolved asset can still be stale or cached incorrectly in production. PR #2722 worked around this by inlining the social-button background colours directly in the template.Solution
Move the entire email stylesheet into a
<style>block insideapp/views/shared_mailers/_header.html.haml. Premailer inlines these rules at delivery time, so the email carries its own CSS and no longer depends on resolving an external stylesheet.Changes
app/assets/stylesheets/email.cssin the<head>ofshared_mailers/_header.app/assets/stylesheets/email.css.background-colorstyles fromshared_mailers/_social(now handled by the embedded.soc-btn.*rules).<style>block is present.shared_mailers/_social:WorkshopInvitationMailer,VirtualWorkshopInvitationMailer,EventInvitationMailer,MeetingInvitationMailer, andFeedbackRequestMailer.Verification
bundle exec rspec spec/mailers/— 75 examples, 0 failures.make test— 1158 examples, 0 failures.bundle exec haml-lint app/views/shared_mailers/_header.html.haml— 0 lints.