UNPKG

htmlnano

Version:

Modular HTML minifier, built on top of the PostHTML

72 lines (69 loc) 2.6 kB
Object.defineProperty(exports, '__esModule', { value: true }); /** * Minify HTML in a safe way without breaking anything. */ var safe = { /* ---------------------------------------- * Attributes * ---------------------------------------- */ // normalize the case of attribute names and values // normalizeAttributeValues will also normalize property value with invalid value default // See https://html.spec.whatwg.org/#invalid-value-default normalizeAttributeValues: true, removeEmptyAttributes: true, collapseAttributeWhitespace: true, // removeRedundantAttributes will remove attributes when missing value default matches the attribute's value // See https://html.spec.whatwg.org/#missing-value-default removeRedundantAttributes: false, // removeXmlLeftovers removes XHTML-era leftovers meaningless in HTML documents. // Max preset only, since it changes documents that are re-served as XHTML/XML. removeXmlLeftovers: false, // collapseBooleanAttributes will also collapse those default state can be omitted collapseBooleanAttributes: { amphtml: false }, deduplicateAttributeValues: true, minifyAttributes: { metaContent: true, redundantWhitespaces: 'safe' }, minifyUrls: false, sortAttributes: false, sortAttributesWithLists: 'alphabetical', /* ---------------------------------------- * Minify HTML content * ---------------------------------------- */ collapseWhitespace: 'conservative', minifyCharacterReferences: true, removeComments: 'safe', removeEmptyElements: false, minifyConditionalComments: false, removeOptionalTags: false, normalizeDoctype: false, removeAttributeQuotes: false, /* ---------------------------------------- * Minify inline <style>, <script> and <svg> tag * ---------------------------------------- */ mergeStyles: false, mergeScripts: false, minifyCss: { preset: 'default' }, minifyHtmlTemplate: true, minifyJs: {}, minifyJson: true, minifySvg: { plugins: [ { name: 'preset-default', params: { overrides: { collapseGroups: false, convertShapeToPath: false } } } ] }, removeUnusedCss: false, /* ---------------------------------------- * Miscellaneous * ---------------------------------------- */ custom: (tree, _options)=>tree }; exports.default = safe;