Giter VIP home page Giter VIP logo

mjml-web's Introduction

mjml-web

npm bundlephobia

Browser-compatible mjml bundle.

Installation

You can install mjml-web with your npm client of choice.

$ npm install mjml-web

Usage

The default export is the mjml2html function. The package also re-exports the content of mjml-core.

  • Webpack (recommended)

    const mjml = await import(/* webpackChunkName: "mjml-web" */ 'mjml-web')
    const { default: mjml2html, registerComponent } = mjml
    
    registerComponent(MyComponent)
    mjml2html('<mjml>...</mjml>')
    // webpack.config.js
    
    const TerserPlugin = require('terser-webpack-plugin')
    
    module.exports = {
      optimization: {
        minimizer: [
          new TerserPlugin({
            exclude: /mjml-web/,
          }),
        ],
      },
    }
  • Browser (codepen)

    <script src="https://unpkg.com/mjml-web"></script>
    const { default: mjml2html, registerComponent } = window.mjml
    
    registerComponent(MyComponent)
    mjml2html('<mjml>...</mjml>')

Troubleshooting

  • Element doesn't exist or is not registered

    You're probably using a bundler that's trying to minify mjml-web alongside your application. The original mjml package isn't meant to be used client-side and the component registration code can break depending on the way it gets minified.

    The solution is to separate mjml-web from the other chunks and exclude it from the minification process (see above).


License - MIT

mjml-web's People

Contributors

dependabot[bot] avatar vberlier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mashiane thomasoj

mjml-web's Issues

Retrieving the compiled HTML

Hi there

I am trying your library via the browser. How do I retrieve the compiled html from mjml?

I'm new to this and trying to find my way.

Thanks.

MJML 4.7 Release

Good day

I have just noted that they have a release of 4.7 for MJML. Without pressure putting on you with your awesome library. Can I please request you to kindly update when possible.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.