Skip to content

Commit

Permalink
fixed image-url custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Aug 13, 2015
1 parent 6019f64 commit fb481d0
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,25 @@ module.exports = function (grunt) {
*/
sassReal: {
options: {
//functions: {
// "image-url($img)": function(img, done) {
// var imgPath = img.getValue(),
// // equivalent to "<%= build_configs.current.siteDir %>assets/img"
// fullPath = path.join(userConfig.build_configs.current.siteDir, imgPath);
//
// var newPath = new sass.types.String(fullPath);
//
// return newPath;
// }
//}
functions: {
"image-url($img)": function(img, done) {
var cwd = process.cwd(),
bd = userConfig.build_dir,
imgPath = path.join(cwd, bd, "assets/img", img.getValue()),
// equivalent to "<%= build_configs.current.siteDir %>assets/img"
sassPath = path.join(cwd, bd, "assets/styles"),
fullPath = path.join(
//userConfig.build_configs.current.siteDir,
path.relative(sassPath, imgPath)
);

fullPath = "url('" + slash(fullPath) + "')";

var newPath = new sass.types.String(fullPath);

return newPath;
}
}
},
build: {
options: {
Expand Down

0 comments on commit fb481d0

Please sign in to comment.