mirror of
https://github.com/remy/inliner.git
synced 2024-10-26 18:49:55 +03:00
9904b6b334
Fixes #58 Compresses inline SVG using SVGO, and compresses CSS background SVG images by making them data URLs (using text/svg+xml mime). Adds CLI (and lib) option: --nosvg which avoids using SVGO for compression (as it can on occassion mess up). Also includes a refactor of the code to organise the files a little better (allowing for further inlined elements to be added).
25 lines
480 B
JavaScript
25 lines
480 B
JavaScript
module.exports = findAssets;
|
|
|
|
var cheerio = require('cheerio');
|
|
var debug = require('debug')('inliner');
|
|
|
|
function findAssets(html, cheerioLoadOptions) {
|
|
var $ = cheerio.load(html, cheerioLoadOptions);
|
|
debug('loaded DOM');
|
|
|
|
var tasks = this.jobs.tasks;
|
|
var res = Object.keys(tasks).reduce(function (acc, task) {
|
|
if (task === 'html') { // skip html task
|
|
return acc;
|
|
}
|
|
|
|
acc[task] = $(tasks[task]);
|
|
|
|
return acc;
|
|
}, {});
|
|
|
|
res.$ = $;
|
|
|
|
return res;
|
|
}
|