first commit
This commit is contained in:
20
vue-ydui/build/rem2px.js
Normal file
20
vue-ydui/build/rem2px.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const postcss = require('postcss');
|
||||
|
||||
module.exports = postcss.plugin('vue-ydui-rem2px', function (size) {
|
||||
return function (css, result) {
|
||||
const oldCssText = css.toString();
|
||||
let newCssText = '';
|
||||
|
||||
if (/\d*\.?\d+rem/.test(oldCssText)) {
|
||||
newCssText = oldCssText.replace(/(\d*\.?\d+)rem/g, function (match, m1) {
|
||||
return parseInt(m1 * size) + 'px';
|
||||
});
|
||||
} else {
|
||||
return oldCssText;
|
||||
}
|
||||
|
||||
result.root = postcss.parse(newCssText);
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user