msidolphin
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
1 deletions
-
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; |
|
|
|
|
|
|
|