diff --git a/package.json b/package.json index b14b0b1..8c70c37 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-cache-bust", "description": "Bust static assets from the cache using content hashing", - "version": "0.4.2", + "version": "0.4.3", "author": "Ben Holland ", "repository": { "type": "git", diff --git a/tasks/cachebust.js b/tasks/cachebust.js index a15948a..aaf42f9 100644 --- a/tasks/cachebust.js +++ b/tasks/cachebust.js @@ -89,17 +89,21 @@ module.exports = function(grunt) { var cssObj = css.parse(data); // Loop through each stylesheet rules - cssObj.stylesheet.rules.forEach(function(rule) { + if(cssObj.stylesheet) { + cssObj.stylesheet.rules.forEach(function(rule) { - // Loop through all declarations - rule.declarations.forEach(function(declaration) { + // Loop through all declarations + if(rule.declarations) { + rule.declarations.forEach(function(declaration) { - // Check if it has a background property, and if so, checkt that it contains a URL - if((/background/).test(declaration.property) && (/url/).test(declaration.value)) { - paths.push(declaration.value.match(/url\(["|']?(.*?)['|"]?\)/)[1]); + // Check if it has a background property, and if so, checkt that it contains a URL + if((/background/).test(declaration.property) && (/url/).test(declaration.value)) { + paths.push(declaration.value.match(/url\(["|']?(.*?)['|"]?\)/)[1]); + } + }); } }); - }); + } } else { // Add any conditional statements or assets in comments to the DOM var assets = '';