这是一个重构工具,试过有项目,原本用着 px 写单位,后来使用 rem 作适配,就要变动单位,有一些项目原本是按照 640 作设计稿宽度,后来作小程序了,作好的页面要变成基于 750 宽度的设计稿,相对的写好的绝对长度就要变。好比 640 里面的 320像素,就要换成 750 标准里面的 375 像素了。
因而我就搞出来这个工具,输入已经写好的 css,配置好相应的转换步骤,便可输出新长度标准的 css 了。
github 地址 下面附上 READMEcss
对传入字符串进行正则替换,能够按顺序执行多个步骤,不 star 一个吗?
(https://github.com/LiangWei88...node
/*错误写法*/ .test { width:16px } /*正确写法, 三种均可以*/ .test { width:16px; margin: 16px 22px; font-size: 32px}
npm i --save design-size-convertor 安装完,
能够把 node node_modules/design-size-convertor/index.js 放入到你的 package.json 的 script 里面webpack
"script" : { "dsc": "node node_modules/design-size-convertor/index.js" }
而后使用 npm run dscgit
到 github 上面直接下载
而后运行 node index.jsgithub
github pageweb