
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@lihaochen/postcss-pxtovw
Advanced tools
A plugin for PostCSS that generates vw units from pixel units.
npm i @lihaochen/postcss-pxtovw -D
// postcss.config.js
module.exports = {
plugins: {
'@lihaochen/postcss-pxtovw': {}
}
}
/* input */
h1 {
margin: 0 0 20px;
font-size: 32px;
line-height: 1.2;
letter-spacing: 1px;
}
/* output */
h1 {
margin: 0 0 5.33333vw;
font-size: 8.53333vw;
line-height: 1.2;
letter-spacing: 1px;
}
viewportWidth
(number): The width of the viewport, default value is 375
.unitPrecision
(number): The decimal numbers to allow the vw units to grow to, default value is 5
.minPixelValue
(number): Set the minimum pixel value to replace, default value is 1
.include
(Rule[]): Only matching files will be converted, default value is [/.*/]
.exclude
(Rule[]): Ignore matching files like 'node_modules', default value is []
.includeProps
(Rule[]): Only matching properies will be converted, default value is [/.*/]
.excludeProps
(Rule[]): Ignore matching properies like 'font-size', default value is []
.includeSelectors
(Rule[]): Only matching selectors will be converted, default value is [/.*/]
.excludeSelectors
(Rule[]): Ignore matching selectors like '.ignore', default value is []
.mediaQuery
(boolean): Allow px to be converted in media queries.The type
Rule
is defined astype Rule = string | RegExp | Function
.
string
: Include given value, likeString.prototype.includes
.RegExp
: By regular matching.Function
: When the return value is true, matching.
// postcss.config.js
module.exports = {
plugins: {
'@lihaochen/postcss-pxtovw': {
viewportWidth: 750,
unitPrecision: 3,
minPixelValue: 1
}
}
}
// postcss.config.js
module.exports = {
plugins: {
'@lihaochen/postcss-pxtovw': {
// Only process files containing the 'src/views/mobile' path.
include: ['src/views/mobile'],
// Do not process files containing the 'node_modules' path.
exclude: ['node_modules']
}
}
}
// postcss.config.js
module.exports = {
plugins: {
'@lihaochen/postcss-pxtovw': {
// Only process properies containing the 'font' name, like 'font-size'.
includeProps: ['font'],
// Do not process properies containing the 'margin' name, like 'margin'/'margin-top'/'margin-bottom'.
includeProps: ['margin']
}
}
}
// postcss.config.js
module.exports = {
plugins: {
'@lihaochen/postcss-pxtovw': {
// Only process selectors containing the 'src/views/mobile' name, like '.mobile'/'.mobile-title'.
includeSelectors: ['mobile'],
// Do not process selectors containing the 'ignore' name, like '.ignore'/'.ignore-rule'.
includeSelectors: ['node_modules']
}
}
}
/* pxtovw-ignore */
.rule {
width: 20px;
height: 20px;
font-size: 15px;
}
.rule {
width: 20px;
height: 20px;
/* pxtovw-ignore */
font-size: 15px;
}
.rule {
width: 20px;
height: 20px;
font-size: 15px;
}
.rule {
width: 5.33333vw;
height: 5.33333vw;
font-size: 15px;
}
FAQs
A CSS post-processor that converts px to vw.
We found that @lihaochen/postcss-pxtovw demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.