nuxt-mjml-web
v4.7.0
Published
Browser-compatible mjml module for NuxtJS
Downloads
10
Readme
nuxt-mjml-web
Browser-compatible mjml module for NuxtJS.
Installation
You can install nuxt-mjml-web
with your npm
client of choice.
$ npm install --save-dev nuxt-mjml-web
Usage
Add nuxt-mjml-web
to the buildModules
section of nuxt.config.js
.
export default {
buildModules: ['nuxt-mjml-web'],
}
The module depends on mjml-web and takes care of isolating the bundle into its own chunk. It also prevents minification from breaking mjml component registration.
import mjml2html, { registerComponent } from 'mjml-web'
registerComponent(MyComponent)
mjml2html('<mjml>...</mjml>')
Keep in mind that the bundle isn't compatible with server-side rendering. You should only import mjml-web
in a client-only context. You can use dynamic imports to only load mjml when you need it.
const { default: mjml2html, registerComponent } = await import('mjml-web')
registerComponent(MyComponent)
mjml2html('<mjml>...</mjml>')
License - MIT