jonathanepollack/gulp-minify-css — pull request #12 by atis-- (2014-04-15 11:25:46+00:00)
Title: set relativeTo option

So let's say I want to minify and concat a bunch of CSS files together. They contain relative image references `url(some/path)` or `url(../some/other/path)` etc. As per docs, to rebase these references correctly, we set the `root` option to desired output directory.

This is the calling gulp code:
```
gulp.src(["public/lib/bootstrap/css/bootstrap-responsive.css",
"public/lib/bootstrap/css/bootstrap.css",
"public/css/*"])
.pipe(minifycss({
keepBreaks: true,
root: path.resolve("public")
}))
.pipe(concat("compiled.css"))
.pipe(gulp.dest("public"));
```

Now, since the references are relative to the CSS files themselves, `clean-css` minifier must be given their location. This requires setting the `relativeTo` option **for each CSS file** to its directory. Presently, there is no such mechanism.

The pull request patch adds this (in my opinion) correct rebasing behavior. This will, however, negate any global `relativeTo` setting from the gulpfile, although a conditional logic could be added to automatically set individual `relativeTo` only if a common option is not provided. A common `relativeTo` to all css files seems
to me like a strange and unnesessary thing but who knows.

I've only been exploring gulp for the past couple of days, and so I don't pretend to know much about it. Rebasing CSS urls seems like a fundamental task and others must've come across this issue. Perhaps I'm doing something wrong altogether?