Skip to content

Commit 0fa0b01

Browse files
committed
Added mjml compilation option to shopware-cli project command
1 parent 40be023 commit 0fa0b01

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ FrameworkBundle
403403
FrankenPHP
404404
FriendsOfShopware
405405
FroshDevelopmentHelper
406+
FroshPlatformTemplateMail
406407
FroshTools
407408
Fullstack
408409
GBP
@@ -523,6 +524,7 @@ MRs
523524
MVC
524525
MailAware
525526
MailHog
527+
Mailjet
526528
MailService
527529
MailStorer
528530
Mailcatcher
@@ -556,6 +558,7 @@ MigrationStep
556558
Minio
557559
Mixin
558560
Mixins
561+
MJML
559562
Modul
560563
Modularity
561564
ModuleFactory

products/cli/project-commands/build.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,61 @@ build:
4545
4646
You can check [here which browsers would be affected](https://browsersl.ist/#q=defaults).
4747
48+
## MJML Email Template Compilation
49+
50+
Starting with Shopware CLI 0.6.32, the `project ci` command can compile MJML email templates during the build process
51+
for projects using the [FroshPlatformTemplateMail](https://github.com/FriendsOfShopware/FroshPlatformTemplateMail) plugin.
52+
[MJML](https://mjml.io) is a markup language designed to reduce the pain of coding responsive emails by providing
53+
semantic components that compile to responsive HTML.
54+
55+
### Prerequisites
56+
57+
This feature is specifically designed for projects using the **FroshPlatformTemplateMail** plugin. The primary purpose of this plugin is to manage email templates as source files in your codebase, rather than storing them in the database. This approach enables:
58+
59+
- **Version control**: Email templates can be tracked in Git alongside your code
60+
- **Deployment consistency**: Templates are deployed with your code, ensuring consistency across environments
61+
- **MJML support**: Optionally write templates in MJML (Mailjet Markup Language) format for responsive emails
62+
- **Build-time compilation**: Since templates are in source files, they can be compiled during the build process
63+
64+
Having email templates in source files is essential for the shopware-cli MJML compilation feature to work, as it processes these files during the build phase.
65+
66+
### Why compile MJML during build?
67+
68+
By default, FroshPlatformTemplateMail compiles MJML templates at runtime when emails are sent. The shopware-cli build-time compilation offers several advantages:
69+
70+
- **Early error detection**: Catch MJML syntax errors during CI/CD instead of when sending emails
71+
- **Better performance**: Eliminate runtime compilation overhead
72+
- **Improved reliability**: Remove potential runtime failures in production
73+
- **Reduced dependencies**: No need for MJML compilation services in production
74+
75+
### Configuration
76+
77+
Enable MJML compilation in your `.shopware-project.yml` file:
78+
79+
```yaml
80+
build:
81+
mjml:
82+
# Enable MJML compilation during build
83+
enabled: true
84+
# Directories to search for MJML templates (defaults to custom/plugins and custom/static-plugins if not specified)
85+
searchPaths:
86+
- custom/plugins
87+
- custom/static-plugins
88+
```
89+
90+
### How it works
91+
92+
When MJML compilation is enabled:
93+
94+
1. The CLI searches for `html.mjml` files in the configured search paths (defaults to `custom/plugins` and `custom/static-plugins`)
95+
2. Each `html.mjml` file is compiled to HTML and saved as `html.twig`
96+
3. The original `html.mjml` files are removed after successful compilation to prevent runtime re-compilation attempts
97+
4. Any compilation errors are reported and cause the build to fail, ensuring broken templates don't reach production
98+
99+
### Requirements
100+
101+
MJML compilation requires the `mjml` package to be installed via NPM in your build environment. The CLI uses local compilation to convert MJML templates to HTML.
102+
48103
## Configuration options
49104

50105
You can configure the build process with a `.shopware-project.yml` file. The following options are available:
@@ -71,6 +126,12 @@ build:
71126
# Allows to force building an extension even when the assets existing. A use-case could be if you used composer patches for a specific extension.
72127
force_extension_build:
73128
- name: 'SomePlugin'
129+
# MJML compilation configuration (see MJML section above for details)
130+
mjml:
131+
enabled: false
132+
searchPaths:
133+
- custom/plugins
134+
- custom/static-plugins
74135
```
75136

76137
## Supporting bundles

0 commit comments

Comments
 (0)