Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 实现 rem2px 插件 #88

Open
amandakelake opened this issue Nov 23, 2019 · 0 comments
Open

Node 实现 rem2px 插件 #88

amandakelake opened this issue Nov 23, 2019 · 0 comments

Comments

@amandakelake
Copy link
Owner

amandakelake commented Nov 23, 2019

大半年没写blog了,先占个小坑
当然,这个没写不是真的没写,只是把这段时间的一些积累和思考都沉淀在自己的md笔记软件里了,没怎么花时间去整理并输出,一部分是工作忙的原因吧,更多是内因,不管怎么说,写博客这个习惯还是要保持下去

插件作用:将项目内的rem单位按照一定的基准比例转换成px单位,支持多项目共同操作

本篇暂时先从node写插件的方法去完成,后面有时间再搞一版babel转AST的方式

核心原理:
1、递归遍历当前目录内的特定文件
2、逐行读取,正则匹配出rem相关内容,数字*基准
3、将新生成的文件内容重新覆盖填写源文件

未完待续,会上代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant