1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-02 12:00:03 +02:00
Files
minifyfromhtml/node_modules/minify/lib/html.js
2020-02-07 22:55:28 +01:00

48 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* сжимаем код через htmlMinify */
'use strict';
const assert = require('assert');
const Minifier = require('html-minifier');
const defaultOptions = {
removeComments: true,
removeCommentsFromCDATA: true,
removeCDATASectionsFromCDATA: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
/* оставляем, поскольку у нас
* в элемент fm генерируеться
* таблица файлов
*/
removeEmptyElements: false,
removeOptionalTags: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true,
};
/**
* minify html data.
*
* @param data
* @param userOptions - (optional) object that may contain an `html` key with an object of options
*/
module.exports = (data, userOptions) => {
assert(data);
const options = {
...defaultOptions,
...userOptions && userOptions.html || {},
};
return Minifier.minify(data, options);
};