Refactored.

This commit is contained in:
Alexandre Gigliotti
2015-07-23 08:28:22 -07:00
parent e5e1f08fba
commit f4085786f6
13 changed files with 180 additions and 65 deletions

21
lib/inline-css-url.js Normal file
View File

@@ -0,0 +1,21 @@
var datauri = require('datauri');
var isLocalPath = require('is-local-path');
var path = require('path');
var rework = require('rework');
var url = require('rework-plugin-url');
var inline = function (css, filePath) {
var basePath = path.dirname(filePath);
css = rework(css)
.use(url(function (url) {
if (isLocalPath(url)) {
url = path.resolve(basePath, url);
url = datauri(url);
}
return url;
}))
.toString();
return css;
};
module.exports = inline;