Skip to content

Commit d36f98a

Browse files
committed
minifier changes:
* test fixed * html-minifier used instead as it comes with mjml
1 parent 2865852 commit d36f98a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"@babel/runtime": "^7.14.6",
4848
"babel-runtime": "~6.25.0",
4949
"color": "^3.1.3",
50-
"html-minifier-terser": "*",
5150
"react-reconciler": "^0.26.1"
5251
},
5352
"babel": {

src/index.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { minify } from 'html-minifier-terser'
21
import ReactDOMServer from 'react-dom/server';
32
import mjml2html from 'mjml';
3+
import { minify as htmlMinify } from 'html-minifier';
44

55
import { renderToJSON } from './utils/render-to-json';
66
import { renderToJSON2 } from './utils/render-to-json2';
@@ -51,16 +51,22 @@ function render(email, options = {}) {
5151
validationLevel: 'strict',
5252
};
5353

54-
const html = mjml2html(renderToMjml(email), { ...defaults, ...options, minify: false });
54+
const html = mjml2html(renderToMjml(email), {
55+
...defaults,
56+
...options,
57+
minify: undefined,
58+
});
5559

5660
if (options.minify) {
57-
return minify(html, {
58-
caseSensitive: true,
59-
collapseWhitespace: true,
60-
minifyCSS: true,
61-
removeComments: true,
62-
removeEmptyAttributes: true
63-
});
61+
return {
62+
html: htmlMinify(html.html, {
63+
caseSensitive: true,
64+
collapseWhitespace: true,
65+
minifyCSS: true,
66+
removeComments: true,
67+
removeEmptyAttributes: true,
68+
}),
69+
};
6470
}
6571

6672
return html;

test/render.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('render()', () => {
3030
</MjmlBody>
3131
</Mjml>
3232
);
33-
const { html } = render(email);
33+
const { html } = render(email, { minify: true });
3434
expect(html).to.not.be.undefined;
3535
expect(html).to.contain('<!doctype html>');
3636
expect(html).to.contain('<title>Title</title>');

0 commit comments

Comments
 (0)