less/less.js — pull request #1811 by bcluca (2014-01-17 05:48:57+00:00)
Title: Cache buster for url tokens

This pull request implements cache busting for url tokens.

The cache buster param can be set via the `--cache-buster` option from the command line:

```bash
$ lessc --cache-buster=424242 urls.less
```

or from JavaScript:

```javascript
parser.parse('.icon { background-image: url(image.png) }', function (e, tree) {
var css = tree.toCSS({ cacheBuster: 424242 });
console.log(css);
});
```

The output CSS looks like this:

```css
.icon {
background-image: url(image.png?424242);
}
```

The cache buster param can also be set to something like `?name=value`. For example, `?rev=424242` can be set with `--cache-buster=rev=424242`.

It takes into account different forms. For instance, the following

```css
.icon { background-image: url(image.png) }
@font-face {
src: url(fonts.svg#MyGeometricModern) format("svg");
}
.icon { background-image: url(image.png?w=120) }
.icon { background-image: url('data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==') }
```

compiles to

```css
.icon {
background-image: url(image.png?rev=424242);
}
@font-face {
src: url(fonts.svg?rev=424242#MyGeometricModern) format("svg");
}
.icon {
background-image: url(image.png?w=120&rev=424242);
}
.icon {
background-image: url('data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==');
}
```

Tests are provided under `test/less/cache-buster` and `test/css/cache-buster`.

Thanks,
Luca