postcss 8格式
This commit is contained in:
parent
29c48d1a4d
commit
bb98bf39a8
|
|
@ -2,12 +2,30 @@
|
||||||
const postcss = require('postcss');
|
const postcss = require('postcss');
|
||||||
const Rpx2px = require('./rpx2px');
|
const Rpx2px = require('./rpx2px');
|
||||||
|
|
||||||
module.exports = postcss.plugin('postcss-rpx2px', function (options) {
|
// module.exports = postcss.plugin('postcss-rpx2px', function (options) {
|
||||||
return function (css, result) {
|
// return function (css, result) {
|
||||||
const oldCssText = css.toString();
|
// const oldCssText = css.toString();
|
||||||
const rpx2pxIns = new Rpx2px(options);
|
// const rpx2pxIns = new Rpx2px(options);
|
||||||
const newCssText = rpx2pxIns.generatePx(oldCssText);
|
// const newCssText = rpx2pxIns.generatePx(oldCssText);
|
||||||
const newCssObj = postcss.parse(newCssText);
|
// const newCssObj = postcss.parse(newCssText);
|
||||||
result.root = newCssObj;
|
// result.root = newCssObj;
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
|
||||||
|
module.exports = function (options) {
|
||||||
|
return {
|
||||||
|
postcssPlugin: 'postcss-rpx2px',
|
||||||
|
Once: function (css, { result, AtRule }) {
|
||||||
|
const oldCssText = css.toString();
|
||||||
|
const rpx2pxIns = new Rpx2px(options);
|
||||||
|
const newCssText = rpx2pxIns.generatePx(oldCssText);
|
||||||
|
const newCssObj = postcss.parse(newCssText);
|
||||||
|
result.root = newCssObj;
|
||||||
|
},
|
||||||
|
// Declaration(decl) {
|
||||||
|
// console.log(decl.toString());
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
||||||
|
module.exports.postcss = true;
|
||||||
Loading…
Reference in New Issue