From fff029b368cbed34ba6556356f674d9ea7f8d217 Mon Sep 17 00:00:00 2001 From: msidolphin Date: Mon, 19 Nov 2018 10:18:15 +0800 Subject: [PATCH] Update index.js --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7bcc46a..533b654 100755 --- a/index.js +++ b/index.js @@ -29,8 +29,16 @@ module.exports = postcss.plugin('postcss-px-to-viewport', function (options) { var pxRegex = new RegExp('"[^"]+"|\'[^\']+\'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)' + opts.unitToConvert, 'ig') return function (css) { - + css.walkDecls(function (decl, i) { + + if (opts.exclude) { + if (Object.prototype.toString.call(opts.exclude) !== '[object RegExp]') { + throw new Error('options.exclude should be RegExp!') + } + if (decl.source.input.file.match(opts.exclude) !== null) return; + } + // This should be the fastest test and will remove most declarations if (decl.value.indexOf(opts.unitToConvert) === -1) return;