webatvantage-webpack-mjml-plugin

Webpack MJML plugin for converting MJML files to a given location

Usage no npm install needed!

<script type="module">
  import webatvantageWebpackMjmlPlugin from 'https://cdn.skypack.dev/webatvantage-webpack-mjml-plugin';
</script>

README

Webatvantage Webpack MJML Plugin

Webpack plugin for converting MJML files to HTML.
Forked from TDE Webpack MJML Plugin.

Install

npm install --save-dev webatvantage-webpack-mjml-plugin

Usage

In your webpack.config.js

const MjmlPlugin = require('webatvantage-webpack-mjml-plugin');

module.exports = {
    // ...
    plugins: [
        new MjmlPlugin(paths.MJML, {
            extension: '.twig',
            outputPath: path.resolve(__dirname, 'path/to/mjml'),
        }),
    ]
};

API:

// webpack.config.js

module.exports = {
    plugins: [
        new MjmlPlugin(inputPath, {
            extension: options.extension,
            outputPath: options.outputPath,
            // MJML options (https://documentation.mjml.io/#inside-node-js)
            filePath: path.resolve(__dirname, 'path/to/file'),
            keepComments: false,
        }),
    ]
}

inputPath

Type: String

The path where MJML files are located

options.extension

Type: String
Default: ".html"

The default output extension

options.outputPath

Type: String
Default: ""

The path where HTML files should be written to

MJML options

Pass optional options to the mjml2html function
List of available options: https://documentation.mjml.io/#inside-node-js

License

MIT © TDE
MIT © Webatvantage