@jsx-email/plugin-minify
Version:
A minify plugin for jsx-email
71 lines • 3.22 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = void 0;
const jsx_email_1 = require("jsx-email");
// Note: rehype is all ESM-only, so for CJS compat we're dynamically importing
// No, we're not going to force ESM on users
const importPlugins = async () => {
const rehypeMinifyAttributeWhitespace = await import('rehype-minify-attribute-whitespace');
const rehypeMinifyCssStyle = await import('rehype-minify-css-style');
const rehypeMinifyEnumeratedAttribute = await import('rehype-minify-enumerated-attribute');
const rehypeMinifyMediaAttribute = await import('rehype-minify-media-attribute');
const rehypeMinifyMetaColor = await import('rehype-minify-meta-color');
const rehypeMinifyMetaContent = await import('rehype-minify-meta-content');
const rehypeMinifyStyleAttribute = await import('rehype-minify-style-attribute');
const rehypeMinifyWhitespace = await import('rehype-minify-whitespace');
const rehypeNormalizeAttributeValueCase = await import('rehype-normalize-attribute-value-case');
const rehypeRemoveComments = await import('rehype-remove-comments');
const rehypeRemoveDuplicateAttributeValues = await import('rehype-remove-duplicate-attribute-values');
const rehypeRemoveEmptyAttribute = await import('rehype-remove-empty-attribute');
const rehypeRemoveExternalScriptContent = await import('rehype-remove-external-script-content');
const rehypeRemoveMetaHttpEquiv = await import('rehype-remove-meta-http-equiv');
const rehypeRemoveStyleTypeCss = await import('rehype-remove-style-type-css');
const rehypeSortAttributeValues = await import('rehype-sort-attribute-values');
const rehypeSortAttributes = await import('rehype-sort-attributes');
return [
rehypeMinifyAttributeWhitespace,
rehypeMinifyCssStyle,
// Note: `rehypeRemoveMetaHttpEquiv` goes before
// `rehypeMinifyEnumeratedAttribute`, as the latter might minify things further.
rehypeRemoveMetaHttpEquiv,
rehypeMinifyEnumeratedAttribute,
rehypeMinifyMediaAttribute,
rehypeMinifyMetaColor,
rehypeMinifyMetaContent,
rehypeMinifyStyleAttribute,
rehypeMinifyWhitespace,
rehypeNormalizeAttributeValueCase,
rehypeRemoveComments,
rehypeRemoveDuplicateAttributeValues,
rehypeRemoveEmptyAttribute,
rehypeRemoveExternalScriptContent,
rehypeRemoveStyleTypeCss,
rehypeSortAttributeValues,
rehypeSortAttributes
].map((mod) => mod.default);
};
const settings = {
allowParseErrors: true,
characterReferences: {
omitOptionalSemicolons: true,
useShortestReferences: true
},
closeEmptyElements: true,
collapseEmptyAttributes: true,
omitOptionalTags: true,
preferUnquoted: false,
quoteSmart: true,
tightAttributes: true,
tightCommaSeparatedLists: true,
tightDoctype: true,
tightSelfClosing: true
};
exports.plugin = {
name: 'root/minify',
process: async () => {
const plugins = await importPlugins();
return { plugins, settings };
},
symbol: jsx_email_1.pluginSymbol
};
//# sourceMappingURL=index.js.map