From 4a7d55f0619444eff61fbedb05e40a755dcb66ae Mon Sep 17 00:00:00 2001 From: Jon Cuthbert Date: Wed, 9 Dec 2015 18:08:12 -0600 Subject: [PATCH] allow dest and map to be functions returning a string --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index de0f6d4..d3988d9 100644 --- a/index.js +++ b/index.js @@ -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); } @@ -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) {