MJML loader for webpack
Converts MJML files to HTML and exports them as string.
Table of Contents
Install
Node.js v6.5 or newer is required.
webpack 2 or newer is required.
Via the yarn client:
$ yarn add --dev mjml-loader webpack
Via the npm client:
$ npm install --save-dev mjml-loader webpack
Usage
Look into the official webpack loaders usage documentation.
At this moment this loader has no options.
Examples
Compile MJML file to HTML file
For transforming a MJML file to a HTML file is better to use mjml cli
or gulp-mjml
.
Inline the MJML result (HTML) into bundle
With this configuration:
// ... module: rules: test: /\.mjml$/ loader: 'mjml-loader' // ...
With this MJML file:
template.mjml
Hello World!
This entry point:
index.js
;console;
The console output will be:
<!--[if !mso]><!--><!--<![endif]--> <!--[if mso]> <table border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;"><tr><td> <![endif]--><!--[if mso]> <table border="0" cellpadding="0" cellspacing="0"><tr><td style="vertical-align:top;width:600px;"> <![endif]-->Hello World!<!--[if mso]> </td></tr></table> <![endif]--><!--[if mso]> </td></tr></table> <![endif]--> <!--[if mso]> <table border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;"><tr><td> <![endif]--><!--[if mso]> </td></tr></table> <![endif]-->
Contribute
Feel free to dive in! Open an issue or submit PRs.
mjml-loader follows the Contributor Covenant Code of Conduct.