mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 04:10:04 +02:00
update node modules
This commit is contained in:
80
node_modules/clean-css/lib/clean.js
generated
vendored
80
node_modules/clean-css/lib/clean.js
generated
vendored
@@ -18,6 +18,7 @@ var inlineRequestFrom = require('./options/inline-request');
|
||||
var inlineTimeoutFrom = require('./options/inline-timeout');
|
||||
var OptimizationLevel = require('./options/optimization-level').OptimizationLevel;
|
||||
var optimizationLevelFrom = require('./options/optimization-level').optimizationLevelFrom;
|
||||
var pluginsFrom = require('./options/plugins');
|
||||
var rebaseFrom = require('./options/rebase');
|
||||
var rebaseToFrom = require('./options/rebase-to');
|
||||
|
||||
@@ -31,14 +32,17 @@ var CleanCSS = module.exports = function CleanCSS(options) {
|
||||
options = options || {};
|
||||
|
||||
this.options = {
|
||||
batch: !!options.batch,
|
||||
compatibility: compatibilityFrom(options.compatibility),
|
||||
explicitRebaseTo: 'rebaseTo' in options,
|
||||
fetch: fetchFrom(options.fetch),
|
||||
format: formatFrom(options.format),
|
||||
inline: inlineFrom(options.inline),
|
||||
inlineRequest: inlineRequestFrom(options.inlineRequest),
|
||||
inlineTimeout: inlineTimeoutFrom(options.inlineTimeout),
|
||||
level: optimizationLevelFrom(options.level),
|
||||
rebase: rebaseFrom(options.rebase),
|
||||
plugins: pluginsFrom(options.plugins),
|
||||
rebase: rebaseFrom(options.rebase, options.rebaseTo),
|
||||
rebaseTo: rebaseToFrom(options.rebaseTo),
|
||||
returnPromise: !!options.returnPromise,
|
||||
sourceMap: !!options.sourceMap,
|
||||
@@ -67,17 +71,78 @@ CleanCSS.prototype.minify = function (input, maybeSourceMap, maybeCallback) {
|
||||
|
||||
if (options.returnPromise) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
minify(input, options, maybeSourceMap, function (errors, output) {
|
||||
minifyAll(input, options, maybeSourceMap, function (errors, output) {
|
||||
return errors ?
|
||||
reject(errors) :
|
||||
resolve(output);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return minify(input, options, maybeSourceMap, maybeCallback);
|
||||
return minifyAll(input, options, maybeSourceMap, maybeCallback);
|
||||
}
|
||||
};
|
||||
|
||||
function minifyAll(input, options, maybeSourceMap, maybeCallback) {
|
||||
if (options.batch && Array.isArray(input)) {
|
||||
return minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback);
|
||||
} else if (options.batch && (typeof input == 'object')) {
|
||||
return minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback);
|
||||
} else {
|
||||
return minify(input, options, maybeSourceMap, maybeCallback);
|
||||
}
|
||||
}
|
||||
|
||||
function minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback) {
|
||||
var callback = typeof maybeCallback == 'function' ?
|
||||
maybeCallback :
|
||||
(typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
|
||||
var errors = [];
|
||||
var outputAsHash = {};
|
||||
var inputValue;
|
||||
var i, l;
|
||||
|
||||
function whenHashBatchDone(innerErrors, output) {
|
||||
outputAsHash = Object.assign(outputAsHash, output);
|
||||
errors.concat(innerErrors);
|
||||
}
|
||||
|
||||
for (i = 0, l = input.length; i < l; i++) {
|
||||
if (typeof input[i] == 'object') {
|
||||
minifyInBatchesFromHash(input[i], options, whenHashBatchDone);
|
||||
} else {
|
||||
inputValue = input[i];
|
||||
|
||||
outputAsHash[inputValue] = minify([inputValue], options);
|
||||
errors.concat(outputAsHash[inputValue].errors);
|
||||
}
|
||||
}
|
||||
|
||||
return callback ?
|
||||
callback(errors.length > 0 ? errors : null, outputAsHash) :
|
||||
outputAsHash;
|
||||
}
|
||||
|
||||
function minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback) {
|
||||
var callback = typeof maybeCallback == 'function' ?
|
||||
maybeCallback :
|
||||
(typeof maybeSourceMap == 'function' ? maybeSourceMap : null);
|
||||
var errors = [];
|
||||
var outputAsHash = {};
|
||||
var inputKey;
|
||||
var inputValue;
|
||||
|
||||
for (inputKey in input) {
|
||||
inputValue = input[inputKey];
|
||||
|
||||
outputAsHash[inputKey] = minify(inputValue.styles, options, inputValue.sourceMap);
|
||||
errors.concat(outputAsHash[inputKey].errors);
|
||||
}
|
||||
|
||||
return callback ?
|
||||
callback(errors.length > 0 ? errors : null, outputAsHash) :
|
||||
outputAsHash;
|
||||
}
|
||||
|
||||
function minify(input, options, maybeSourceMap, maybeCallback) {
|
||||
var sourceMap = typeof maybeSourceMap != 'function' ?
|
||||
maybeSourceMap :
|
||||
@@ -106,11 +171,20 @@ function minify(input, options, maybeSourceMap, maybeCallback) {
|
||||
validator: validator(options.compatibility),
|
||||
warnings: []
|
||||
};
|
||||
var implicitRebaseToWarning;
|
||||
|
||||
if (sourceMap) {
|
||||
context.inputSourceMapTracker.track(undefined, sourceMap);
|
||||
}
|
||||
|
||||
if (options.rebase && !options.explicitRebaseTo) {
|
||||
implicitRebaseToWarning =
|
||||
'You have set `rebase: true` without giving `rebaseTo` option, which, in this case, defaults to the current working directory. ' +
|
||||
'You are then warned this can lead to unexpected URL rebasing (aka here be dragons)! ' +
|
||||
'If you are OK with the clean-css output, then you can get rid of this warning by giving clean-css a `rebaseTo: process.cwd()` option.';
|
||||
context.warnings.push(implicitRebaseToWarning);
|
||||
}
|
||||
|
||||
return runner(context.localOnly)(function () {
|
||||
return readSources(input, context, function (tokens) {
|
||||
var serialize = context.options.sourceMap ?
|
||||
|
Reference in New Issue
Block a user