Search code examples
gulphtml-emailmjml

Add self-closing tags using juicePreserveTags options within an MJML Gulp task


I'm using a clone of the git Repo: https://github.com/jpagano/mjml-starter-base

How can I add the configuration options found here https://www.gitmemory.com/issue/mjmlio/mjml/1528/467101657

config.juicePreserveTags='{"imgTag": { "start": "<img", "end": "/>" }, "brTag": { "start": "<br", "end": "/>" }}'

I have tried that:

export function buildMjml() {
  const options = {
    beautify: true,
    minify: false,
    keepComments: false,
    juicePreserveTags: '{"imgTag": { "start": "<img", "end": "/>" }, "brTag": { "start": "<br", "end": "/>" }}',
  };

  return gulp.src(PATHS.mjml.src).pipe(mjmlGulp(mjml, options)).pipe(gulp.dest(PATHS.dist));
}

But this don't add the closing tags to the image and br tags


Solution

  • the options should be set as a valid js object.

    juicePreserveTags: {
      imgTag: { "start": "<img", "end": "/>" }, 
      brTag: { "start": "<br", "end": "/>" }
    },