Skip to content

Support url() syntax for asset hashing #14

@jsakas

Description

@jsakas

One suggestion is to support url() for asset_cache_buster. Then this could also be used for an asset hashing tool regardless of compass migration.

Use case:

We have a file hashmap.json hash map that we generate on build that tells the backend / frontend where to find the files.

{
  "images/image.png": "/static/fd9a859f1205a0b5d5b2d6c9f28aee0f274cd4d9/images/image.png"
}

Then in grunt I am using your plugin like:

assetHashMap = JSON.parse(fs.readFileSync('hashmap.json'));

[...]

  sass: {
    options: {
      functions: assetFunctions({
        asset_cache_buster: function(http_path, real_path, done) {
          var hash_path;
          hash_path = assetHashMap[http_path];
          return done({
            path: hash_path,
            query: null
          });
        }
      })
    }
  }

In my Sass I am calling the image like:

body {
  background: image-url('image.png');
}

This works great! But, it would be awesome if I could migrate off of compass syntax entirely and use url(), like this:

body {
  background: url('images/image.png');
}

I will try to fork and update if I can, but it may be something easy for the original developers to add if they feel it would be a nice addition.

I have found this tool to be very helpful in my transition from compass to node-sass. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions