Gathering detailed insights and metrics for postcss-px-to-relative-unit
Gathering detailed insights and metrics for postcss-px-to-relative-unit
Gathering detailed insights and metrics for postcss-px-to-relative-unit
Gathering detailed insights and metrics for postcss-px-to-relative-unit
A postcss plugin to convert px to relative length units (vw / rem)
npm install postcss-px-to-relative-unit
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
98.8
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (82.58%)
CSS (17.42%)
Total Downloads
2,375
Last Day
2
Last Week
9
Last Month
34
Last Year
312
MIT License
7 Stars
6 Commits
2 Forks
1 Watchers
3 Branches
1 Contributors
Updated on Mar 29, 2024
Latest Version
2.0.0
Package Id
postcss-px-to-relative-unit@2.0.0
Unpacked Size
12.57 kB
Size
4.04 kB
File Count
17
NPM Version
6.14.15
Node Version
14.17.6
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
28.6%
9
Compared to previous week
Last Month
-20.9%
34
Compared to previous month
Last Year
-0.3%
312
Compared to previous year
A Postcss plugin to convert px to relative length units (vw / rem)
1npm install postcss-px-to-relative-unit
1// webpack.config.js 2const pxToUnit = require('postcss-px-to-relative-unit') 3 4... 5{ 6 loader: 'postcss-loader', 7 plugins: [ 8 pxToUnit({ 9 // options 10 }) 11 ] 12} 13...
1pxToUnit({ 2 targetUnit: "vw", 3 ignoreThreshold: 1, 4 viewportWidth: 375, 5 viewportHeight: 667, 6 htmlFontSize: 37.5, 7 unitPrecision: 5, 8 excludeFiles: [], 9 excludeSelectors: [], 10 excludeProperties: [], 11});
Options | Default | Description |
---|---|---|
targetUnit | 'vw' | target relative length unit. Support 'vw', 'rem' and 'vw&rem' |
ignoreThreshold | 1 | px values less than this threshold won't be converted |
viewportWidth | 375 | base viewport width (for targetUnit: 'vw' ) |
viewportHeight | 667 | base viewport height (for targetUnit: 'vw', currently useless) |
htmlFontSize | 37.5 | base html font-size (for targetUnit: 'rem') |
unitPrecision | 5 | unit value precision |
excludeFiles | [] | exclude file path, support regexp. (example: [/node_modules/]) |
excludeSelectors | [] | exclude css selector, support string and regexp. (example: ['.ignore']) |
excludeProperties | [] | exclude css properties, support string and regexp. (example: [/^width$/]) |
If you want to use unit vw and also worry about browser support, you can use 'vw&rem' mode. For example:
1// Input 2.test { 3 border: 3.75px solid #fff; 4} 5 6// Output 7.test { 8 border: 0.1rem solid #fff; 9 border: 1vw solid #fff; 10}
For browser doesn't support vw, it will automatically use rem to layout.
Notice: If you need to limit max/min width of the layout, this mode is not suit for you
Convert process is case sensitive, you could use PX in some edge case.
1// Input 2.test { 3 padding: 3.75px 3.75px; 4} 5 6// Output 7.test { 8 padding: 3.75px 1vw; 9}
This project is licensed under the MIT License - see the LICENSE file for details
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
13 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