summaryrefslogtreecommitdiff
path: root/node_modules/postcss-vmin/index.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:20:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:20:49 +0800
commitc5a5384e846f242e901e859fe600d695d8990a9a (patch)
tree079d4ccf2ed93dc1f0cae74a6d3b4a42ac387ece /node_modules/postcss-vmin/index.js
parentd261b7aafee0e6e5c7b853cb8dfe609cc0a0ac9e (diff)
legacy browser support via plugins from postcss
Diffstat (limited to 'node_modules/postcss-vmin/index.js')
-rw-r--r--node_modules/postcss-vmin/index.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/node_modules/postcss-vmin/index.js b/node_modules/postcss-vmin/index.js
new file mode 100644
index 00000000..121d2f79
--- /dev/null
+++ b/node_modules/postcss-vmin/index.js
@@ -0,0 +1,29 @@
+var postcss = require('postcss');
+
+module.exports = postcss.plugin("postcss-vmin", function (opts) {
+ opts = opts || {};
+
+ var REGEX = /(\d*\.?\d+)vmin/ig;
+
+ return function (css) {
+
+ // for each rules, each decl
+ css.walkRules(function (rule) {
+ rule.walkDecls(function (decl, i) {
+
+ if (decl.value.indexOf('vmin') === -1) { return; }
+
+ if (REGEX.exec(decl.value) !== null) {
+ var value = decl.value.replace(REGEX, function (_, number) {
+ return number + 'vm';
+ });
+ rule.insertBefore(i, decl.clone({ value: value }));
+ }
+
+ });
+ });
+
+ return css;
+
+ };
+});