Created
July 10, 2015 22:23
-
-
Save eightdotthree/c157b95e2738c0bff8c7 to your computer and use it in GitHub Desktop.
Usemin file for extracting attributes from CSS files. Used to maintain the data-skrollr-stylesheet attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt, options){ | |
var yeoman = options.yeoman; | |
return { | |
options: { | |
dirs: [yeoman.dist], | |
blockReplacements: { | |
css: function(block) { | |
/** | |
* Find the first of the raw blocks that matches as a link, then extract the string to the left | |
* and the right of the href and put the new dest path in the middle of them, the keeping any | |
* attributes. Note: the attributes applied to the first link tag will be used, so if differnt | |
* attributes are required for different files, they need to be in their own block */ | |
var result = ''; | |
for(var i=0; i<block.raw.length; i++) { | |
if(block.raw[i].match(/\s*<link[^\>]+href=['"][^"']+["']/gm)) { | |
result = block.raw[i].replace(/\s*(<link[^\>]+href=['"])[^"']+(["'])/gm, '$1' + block.dest + '$2'); | |
break; | |
} | |
} | |
return result; | |
} | |
} | |
}, | |
html: [yeoman.dist + '/{,*/}*.html'], | |
css: [yeoman.dist + '/css/{,*/}*.css'] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found on Stack Overflow or GitHub in a comment but I lost the link.