mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 12:20:04 +02:00
update minify
This commit is contained in:
22
node_modules/minify/lib/img.js
generated
vendored
22
node_modules/minify/lib/img.js
generated
vendored
@@ -2,15 +2,15 @@
|
||||
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
const {
|
||||
promisify,
|
||||
} = require('util');
|
||||
const {promisify} = require('util');
|
||||
|
||||
const fromString = promisify(require('css-b64-images').fromString);
|
||||
|
||||
const ONE_KB = Math.pow(2, 10);
|
||||
const ONE_KB = 2 ** 10;
|
||||
|
||||
const maxSize = 100 * ONE_KB;
|
||||
const defaultOptions = {
|
||||
maxSize: 100 * ONE_KB,
|
||||
};
|
||||
|
||||
/**
|
||||
* minify css data.
|
||||
@@ -18,16 +18,20 @@ const maxSize = 100 * ONE_KB;
|
||||
*
|
||||
* @param name
|
||||
* @param data
|
||||
* @param userOptions - (optional) object that may contain an `img` key with an object of options
|
||||
*/
|
||||
module.exports = async (name, data) => {
|
||||
module.exports = async (name, data, userOptions) => {
|
||||
const dir = path.dirname(name);
|
||||
const dirRelative = dir + '/../';
|
||||
|
||||
const options = {
|
||||
...defaultOptions,
|
||||
...userOptions && userOptions.img || {},
|
||||
};
|
||||
|
||||
assert(name);
|
||||
assert(data);
|
||||
|
||||
return fromString(data, dir, dirRelative, {
|
||||
maxSize
|
||||
});
|
||||
return fromString(data, dir, dirRelative, options);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user