Gathering detailed insights and metrics for postcss-relaxed-unit
Gathering detailed insights and metrics for postcss-relaxed-unit
Gathering detailed insights and metrics for postcss-relaxed-unit
Gathering detailed insights and metrics for postcss-relaxed-unit
🍮Postcss-relaxed-unit is a postcss plugin for unit tranformation and make write css easier with custom unit.
npm install postcss-relaxed-unit
Typescript
Module System
69.4
Supply Chain
98.3
Quality
75.5
Maintenance
50
Vulnerability
100
License
TypeScript (88.42%)
JavaScript (11.21%)
CSS (0.38%)
Total Downloads
5,857
Last Day
1
Last Week
17
Last Month
114
Last Year
2,012
MIT License
46 Stars
59 Commits
2 Forks
2 Watchers
3 Branches
2 Contributors
Updated on Nov 14, 2024
Minified
Minified + Gzipped
Latest Version
1.1.1
Package Id
postcss-relaxed-unit@1.1.1
Unpacked Size
15.44 kB
Size
5.59 kB
File Count
27
Cumulative downloads
Total Downloads
Last Day
-66.7%
1
Compared to previous day
Last Week
13.3%
17
Compared to previous week
Last Month
-42.4%
114
Compared to previous month
Last Year
184.6%
2,012
Compared to previous year
English doc | 中文文档
Postcss-relaxed-unit is a postcss plugin for unit tranformation and make write css easier with custom unit.
You can define a rule to determine the mapping relationship between custom unit and target unit, and you can use some operators to calculate the target value (like add
, sub
, mul
, div
, unit
), so you can write style relaxed without care about calculate unit.
Sometimes, we need to care about calculating the style values, for example, px
to rem
, rem
to vw
, px
to whatever that mobile side need and we don't need many plugins. so, postcss-relaxed-unit
can help you forget that, you just need define a rule that describes the custom unit to target unit mapping! that's all! :tada:
You don't have to care about precision overflow, because postcss-relaxed-unit
wraps bignumber.js
.
postcss-relaxed-unit
is publish to npm
,so you can install it using npm
or yarn
npm i postcss-relaxed-unit -D
or
yarn add postcss-relaxed-unit -D
because postcss-relaxed-unit
is depends on PostCSS, you need to install postcss.
You only need to define rule to get start~
postcss.config.js
1const RelaxedUnit = require("postcss-relaxed-unit"); 2 3module.exports = { 4 plugins: [ 5 RelaxedUnit({ 6 rules: { rx: "add(1).sub(2).mul(3).div(9).unit(rem)" } 7 }) 8 ] 9};
You can define more rules :)
1const RelaxedUnit = require("postcss-relaxed-unit"); 2 3module.exports = { 4 plugins: [ 5 RelaxedUnit({ 6 rules: { 7 rx: "add(1).sub(2).mul(3).div(9).unit(rem)", 8 ex: "div(100).unit(rem)" 9 } 10 }) 11 ] 12};
In Nuxt.js
, you need to define the config in nuxt.config.js
nuxt.config.js
1module.exports = { 2 build: { 3 extractCSS: true, 4 postcss: { 5 plugins: { 6 'postcss-relaxed-unit': { 7 rules: { rx: 'div(100).unit(rem)' }, 8 }, 9 }, 10 }, 11}
rules {[custom unit name]: 'operators'}
custom unit to target unit mapping container
add Operator
target value plus +
sub Operator
target value subtraction -
mul Operator
target value multiplication *
div Operator
target value divition /
unit Operator
unit of output
custom unit will output does not change missing unit
Operator, e.g.
1{ 2 "postcss-relaxed-unit": { 3 "rules": { "rx": "add(10).sub(2)" } 4 } 5}
origin style
1.hello-relaxed-unit { 2 width: 10rx; 3}
output style
1.hello-relaxed-unit { 2 width: 18rx; 3}
The signature of operator function like
1type OperatorFunction = (arg: number | string) => string;
so, if you call the operator function like add(aas)
, it will compile passing, the aas
wiil be convert to 0
.
1{"rx": "add(aas).unit(px)"} => {"rx": "add(0).unit(px)"}
run yarn example
or npm run example
if you want to see the results of postcss-relaxed-unit
working.⚙️
MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/6 approved changesets -- score normalized to 1
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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
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