You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: products/cli/project-commands/build.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,61 @@ build:
45
45
46
46
You can check [here which browsers would be affected](https://browsersl.ist/#q=defaults).
47
47
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
- **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
+
48
103
## Configuration options
49
104
50
105
You can configure the build process with a `.shopware-project.yml` file. The following options are available:
@@ -71,6 +126,12 @@ build:
71
126
# 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.
72
127
force_extension_build:
73
128
- name: 'SomePlugin'
129
+
# MJML compilation configuration (see MJML section above for details)
0 commit comments