Gathering detailed insights and metrics for postcss-rpx-plugin
Gathering detailed insights and metrics for postcss-rpx-plugin
Gathering detailed insights and metrics for postcss-rpx-plugin
Gathering detailed insights and metrics for postcss-rpx-plugin
postcss-pxtransform
PostCSS plugin px 转小程序 rpx及h5 rem 单位
postcss-plugin-rpx2vw
Postcss plugin transform rpx to vw or rem.
postcss-rem-to-responsive-pixel
Convert rem units to px or rpx units using PostCSS. Based on postcss-pxtorem and postcss-rem-to-pixel, and rewrite with typescript, and support Postcss8
postcss-rpx-transform
Let's make rpx great again! convert rpx (responsive-pixel) to px,rem,vw
npm install postcss-rpx-plugin
Typescript
Module System
Node Version
NPM Version
68.3
Supply Chain
99.3
Quality
75.6
Maintenance
100
Vulnerability
80.9
License
JavaScript (100%)
Total Downloads
2,112
Last Day
1
Last Week
9
Last Month
37
Last Year
484
GPL-3.0 License
3 Stars
10 Commits
2 Forks
1 Watchers
2 Branches
1 Contributors
Updated on Apr 11, 2023
Minified
Minified + Gzipped
Latest Version
2.0.1
Package Id
postcss-rpx-plugin@2.0.1
Unpacked Size
48.93 kB
Size
15.85 kB
File Count
7
NPM Version
8.7.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-10%
9
Compared to previous week
Last Month
-14%
37
Compared to previous month
Last Year
18.3%
484
Compared to previous year
Based on postcss
A plug-in for converting rpx units in CSS into VW units. It is applicable to the design draft with fixed width and uncertain height in the mobile end. You can also set the width and matching unit by yourself.
1/* before */ 2.rule { 3 margin: 10rpx 375rpx 0rpx 10px; 4 height: 375rpx; 5 background: url(icon-16rpx.jpg); 6} 7 8/* after */ 9.rule { 10 margin: 1.33333vw 50vw 0 10px; 11 height: 50vw; 12 background: url(icon-16rpx.jpg); 13}
First install postcss-loader
And postcss
。 CLI with CSS loader integrated can skip this step
1npm i postcss postcss-loader -D
Install the plug-in
1npm i postcss-rpx-plugin -D
Please use the version of postcss@7 postcss@6 postcss@5
1# postcss@7 postcss@6 postcss@5 2npm i postcss-rpx-plugin@1.0.3 -D
in postcss.config.js
1module.exports = { 2 plugins: [ 3 // register 4 require("postcss-rpx-plugin"), 5 ], 6};
custom configure postcss.config.js
1module.exports = { 2 plugins: [ 3 [ 4 "postcss-rpx-plugin", 5 { 6 unit: "rpx", 7 width: 750, 8 precision: 5, 9 outUnit: "vw", 10 exclude: "", 11 }, 12 ], 13 ], 14};
or in package.json
1{ 2 "dependencies": {}, 3 "devDependencies": {}, 4 "postcss": { 5 "plugins": { 6 "postcss-rpx-plugin": { 7 "unit": "rpx", 8 "width": 750, 9 "precision": 5, 10 "outUnit": "vw", 11 "exclude": "" 12 } 13 } 14 } 15}
1const unit = options?.unit || "rpx"; // unit 2const width = options?.width || 750; // ui design width 3const precision = options?.precision || 5; // decimal places 4const outUnit = options?.outUnit || "vw"; // out unit 5const exclude = options?.exclude || ""; // exclude some file,support regex
1it("should exclude file", () => { 2 const rules = ".rule { margin: 10rpx 375rpx 0rpx 10px; }"; 3 const expected = ".rule { margin: 10rpx 375rpx 0rpx 10px; }"; 4 const from = "c:/a/b/c/d.css"; 5 const pc = postcss(rpx2vm({ exclude: ".css" })); 6 const processed = pc.process(rules, { from }).css; 7 expect(processed).toBe(expected); 8});
options?.unit
error@type
?Float rpx
1it("should replace the rpx unit with vw - Float", () => { 2 const rules = ".rule { height: 375.0rpx; }"; 3 const expected = ".rule { height: 50vw; }"; 4 const processed = postcss(rpx2vm()).process(rules).css; 5 expect(processed).toBe(expected); 6});
url ignore
1it("should not replace values in `url()`", () => { 2 const rules = ".rule { background: url(icon-16rpx.jpg); }"; 3 const expected = ".rule { background: url(icon-16rpx.jpg); }"; 4 const processed = postcss(rpx2vm()).process(rules).css; 5 expect(processed).toBe(expected); 6});
1it("should replace the rpx unit with vw - Int", () => { 2 const rules = ".rule { margin: 10rpx 375rpx 0rpx 10px; }"; 3 const expected = ".rule { margin: 1.33333vw 50vw 0 10px; }"; 4 const processed = postcss(rpx2vm()).process(rules).css; 5 expect(processed).toBe(expected); 6});
You are welcome to put forward your ideas and feedback issues
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
24 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More