-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-26551] MJML build script #6417
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
Conversation
(cherry picked from commit 24783ee)
New Issues (2)Checkmarx found the following issues in this Pull Request
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6417 +/- ##
=======================================
Coverage 50.55% 50.55%
=======================================
Files 1853 1853
Lines 82144 82144
Branches 7254 7254
=======================================
Hits 41525 41525
Misses 39036 39036
Partials 1583 1583 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 is so helpful, thank you! I've made a few suggestions.
src/Core/MailTemplates/README.md
Outdated
These are the compiled HTML email templates that serve as the foundation for all HTML emails sent by the Bitwarden platform. They are generated from MJML source files and enhanced with Handlebars templating capabilities. | ||
|
||
### Generation Process | ||
- **Source**: Built from `*.mjml` files in the `./mjml` directory using the MJML build pipeline |
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.
- **Source**: Built from `*.mjml` files in the `./mjml` directory using the MJML build pipeline | |
- **Source**: Built from `*.mjml` files in the `./mjml` directory using the MJML build pipeline by the developer as they construct the email |
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.
src/Core/MailTemplates/README.md
Outdated
|
||
### Generation Process | ||
- **Source**: Built from `*.mjml` files in the `./mjml` directory using the MJML build pipeline | ||
- **Build Tool**: Generated via PowerShell build script (`build.ps1`) or npm scripts |
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.
We should clarify what npm scripts we're referring to here.
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.
And link to any of them we can.
# MJML email templating | ||
|
||
This directory contains MJML templates for emails sent by the application. MJML is a markup language designed to reduce the pain of coding responsive email templates. | ||
This directory contains MJML templates for emails. MJML is a markup language designed to reduce the pain of coding responsive email templates. There are DRY features within the library which will improve code quality. |
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'd suggest that we clarify what DRY is instead of using the acronym. Perhaps "The library allows us to introduce reusable components that reduce repeated code"?
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.
```bash | ||
## Implementation considerations | ||
|
||
These `MJML` templates are compiled into HTML which will then be further consumed by our HandleBars mail service. We can continue to use this service to assign values from our View Models. This leverages the existing infrastructure. It also means we can continue to use the double brace (`{{}}`) syntax within MJML since Handlebars can be used to assign values to those `{{variables}}`. |
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.
These `MJML` templates are compiled into HTML which will then be further consumed by our HandleBars mail service. We can continue to use this service to assign values from our View Models. This leverages the existing infrastructure. It also means we can continue to use the double brace (`{{}}`) syntax within MJML since Handlebars can be used to assign values to those `{{variables}}`. | |
These `MJML` templates are compiled into HTML which will then be further consumed by our Handlebars mail service. We can continue to use this service to assign values from our View Models. This leverages the existing infrastructure. It also means we can continue to use the double brace (`{{}}`) syntax within MJML since Handlebars can be used to assign values to those `{{variables}}`. |
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.
|
||
Not all MJML tags have the same attributes, it is highly recommended to review the documentation on the official MJML website to understand the usages of each of the tags. | ||
|
||
### Possible process |
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.
### Possible process | |
### Recommended development process |
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.
Added information about build script definitions for MJML.
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.
What is the goal of this PR? It looks like it is more than just Windows compat, because the previous build script was 2 lines and the new one is >100? Could you update the PR description?
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 is good from my perspective. We can revisit build and tooling optimizations 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.
Thank you for all of your work on this!
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.
If you have availability and the timeline to merge this is flexible enough, I would appreciate it if you take a pass at making this more maintainable for UIF with my following suggestions. However, I also recognize that this script is fairly simple, so I am not going to block it going in if it needs to.
- Use Typescript via Node's built in type stripping
- Use ESM imports
- Use a lightweight CLI builder like https://github.com/unjs/citty
- Tests
(I would recommend asking an LLM to help with this!)
* docs: update readme for MJML * docs: add readme for MailTemplates directory * feat: add node build script for cross platform build support
🎟️ Tracking
PM-26551
📔 Objective
There is no general build support for MJML templates currently. The changes here are meant to give developers the tools needed to generate
*.html.hbs
files using MJML templating.The build script supports compiling MJML templates to:
.html
:npm run build
.html.hbs
:npm run build:hbs
.html.hbs
:npm run build:minify
A watch feature is included which compiles the MJML template to
HTML
, as well as a prettier feature.⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes