1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-04 04:40:05 +02:00

use minify

This commit is contained in:
s2
2019-04-15 10:35:12 +02:00
parent 9528e1e8e1
commit 86e1333c3e
9417 changed files with 70210 additions and 462173 deletions

View File

@@ -1,3 +1,5 @@
var systemLineBreak = require('os').EOL;
var override = require('../utils/override');
var Breaks = {
@@ -12,6 +14,12 @@ var Breaks = {
BetweenSelectors: 'betweenSelectors'
};
var BreakWith = {
CarriageReturnLineFeed: '\r\n',
LineFeed: '\n',
System: systemLineBreak
};
var IndentWith = {
Space: ' ',
Tab: '\t'
@@ -25,10 +33,12 @@ var Spaces = {
var DEFAULTS = {
breaks: breaks(false),
breakWith: BreakWith.System,
indentBy: 0,
indentWith: IndentWith.Space,
spaces: spaces(false),
wrapAt: false
wrapAt: false,
semicolonAfterLastProperty: false
};
var BEAUTIFY_ALIAS = 'beautify';
@@ -75,6 +85,10 @@ function formatFrom(source) {
return false;
}
if (typeof source == 'object' && 'breakWith' in source) {
source = override(source, { breakWith: mapBreakWith(source.breakWith) });
}
if (typeof source == 'object' && 'indentBy' in source) {
source = override(source, { indentBy: parseInt(source.indentBy) });
}
@@ -133,6 +147,8 @@ function toHash(string) {
accumulator[name] = parseInt(value);
} else if (name == 'indentWith') {
accumulator[name] = mapIndentWith(value);
} else if (name == 'breakWith') {
accumulator[name] = mapBreakWith(value);
}
return accumulator;
@@ -167,6 +183,21 @@ function normalizeValue(value) {
}
}
function mapBreakWith(value) {
switch (value) {
case 'windows':
case 'crlf':
case BreakWith.CarriageReturnLineFeed:
return BreakWith.CarriageReturnLineFeed;
case 'unix':
case 'lf':
case BreakWith.LineFeed:
return BreakWith.LineFeed;
default:
return systemLineBreak;
}
}
function mapIndentWith(value) {
switch (value) {
case 'space':