Skip to content

Commit

Permalink
Merge pull request #13 from cuth/feature/function-dest
Browse files Browse the repository at this point in the history
Allow dest path and map to be functions returning a string,
prevent creating empty file.
  • Loading branch information
Ser-Gen committed Dec 14, 2015
2 parents 59e4d40 + 4a7d55f commit f362cfb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function plugin (opts) {

return function (css, result) {

opts.from = result.opts.from;
opts.to = result.opts.to;

if (opts.dest !== false) {
generateDataFile(css, opts);
}
Expand Down Expand Up @@ -175,10 +178,12 @@ function generateDataFile (css, opts) {
};

var data = dataCSS.toResult({
to: opts.dest.path,
map: opts.dest.map
to: (typeof opts.dest.path === 'function') ? opts.dest.path(opts) : opts.dest.path,
map: (typeof opts.dest.map === 'function') ? opts.dest.map(opts) : opts.dest.map
});

if (!data.css.length) return;

fsExtra.outputFileSync(data.opts.to, data.css);

if (data.map) {
Expand Down

0 comments on commit f362cfb

Please sign in to comment.