diff --git a/lib/cachebust.js b/lib/cachebust.js
index b818ec7..a2d1deb 100644
--- a/lib/cachebust.js
+++ b/lib/cachebust.js
@@ -32,8 +32,13 @@ exports.busted = function(fileContents, options) {
self.MD5 = function(fileContents, originalAttrValue, options) {
var originalAttrValueWithoutCacheBusting = originalAttrValue.split("?")[0],
- hash = MD5(fs.readFileSync(options.basePath + originalAttrValueWithoutCacheBusting).toString());
+ filePath = options.basePath + originalAttrValueWithoutCacheBusting;
+ if (!fs.existsSync(filePath)) {
+ return fileContents;
+ }
+
+ var hash = MD5(fs.readFileSync(filePath).toString());
return fileContents.replace(originalAttrValue, originalAttrValueWithoutCacheBusting + '?v=' + hash);
};
diff --git a/test/fixtures/default_options.html b/test/fixtures/default_options.html
index f845fae..a95357b 100644
--- a/test/fixtures/default_options.html
+++ b/test/fixtures/default_options.html
@@ -17,5 +17,6 @@