Fix bug where bundler stops watching files when an error occurs.

This commit is contained in:
Alexandre Gigliotti
2015-10-07 11:54:47 -07:00
parent f28f0e718a
commit c7ca7bfc75
13 changed files with 342 additions and 134 deletions

View File

@@ -28,26 +28,34 @@ var clean = function (path) {
* @param filename
* @returns {{css: (css|any), files: Array}}
*/
var inline = function (css, filename) {
var inlineUrl = function (css, filename) {
var files = [];
var basePath = path.dirname(filename);
var result = postcss()
.use(postcssUrl({
url: function (urlPath) {
if (isLocalPath(urlPath) && !isTemplateExpression(urlPath)) {
urlPath = clean(urlPath);
urlPath = path.resolve(basePath, urlPath);
files.push(urlPath);
urlPath = datauri(urlPath);
try {
urlPath = clean(urlPath);
urlPath = path.resolve(basePath, urlPath);
files = R.append(urlPath, files);
urlPath = datauri(urlPath);
}
catch (error) {
error.filename = filename;
error.files = R.uniq(files);
throw error;
}
}
return urlPath;
}
}))
.process(css);
files = R.uniq(files);
return {
css: result.css,
files: files
files
};
};
module.exports = inline;
module.exports = inlineUrl;