mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-02 20:00:05 +02:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
/* сжимаем код через htmlMinify */
|
||
|
||
'use strict';
|
||
|
||
const assert = require('assert');
|
||
const Minifier = require('html-minifier');
|
||
|
||
const Options = {
|
||
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 callback
|
||
*/
|
||
module.exports = (data) => {
|
||
assert(data);
|
||
|
||
return Minifier.minify(data, Options);
|
||
};
|
||
|