Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
postcss-pixel-to-vw
Advanced tools
A plugin for PostCSS that generates vw units from pixel units.
If your project involves a fixed width, this script will help to convert pixels into vw units.
// input
.class {
margin: -10px .5vh;
padding: 5vmin 9.5px 1px;
border: 3px solid black;
border-bottom-width: 1px;
font-size: 14px;/*vw*/
line-height: 20px;/*px*/
}
.class2 {
border: 1px solid black;
margin-bottom: 1px;
font-size: 20px;
line-height: 30px;
}
@media (min-width: 750px) {
.class3 {
font-size: 16px;
line-height: 22px;
}
}
// output
.class {
margin: -1.33333vw .5vh;
padding: 5vmin 1.26667vw 1px;
border: 0.4vw solid black;
border-bottom-width: 1px;
font-size: 1.86667vw;
line-height: 20px;
}
.class2 {
border: 1px solid black;
margin-bottom: 1px;
font-size: 20px;
line-height: 4vw;
}
@media (min-width: 750px) {
.class3 {
font-size: 16px;
line-height: 2.93333vw;
}
}
'use strict';
var fs = require('fs');
var postcss = require('postcss');
var px2vw = require('..');
var css = fs.readFileSync('main.css', 'utf8');
var options = {
propertyBlackList: ['font-size']
};
var processedCss = postcss(px2vw(options)).process(css).css;
fs.writeFile('main-viewport.css', processedCss, function (err) {
if (err) {
throw err;
}
console.log('File with viewport units written.');
});
Default:
{
viewportWidth: 750,
propertyBlackList: [],
minPixelValue: 2,
mediaQuery: false
}
viewportWidth
(Number) The width of the viewport.propertyBlackList
(Array) The propertys to ignore and leave as px.
['font']
will match font-size
[/^font$/]
will match font
but not font-size
minPixelValue
(Number) Set the minimum pixel value to replace.mediaQuery
(Boolean) Allow px to be converted in media queries.font-size: 14px;/*px*/
will not transform px to vw.font-size: 14px;/*vw*/
will transform px to vw, if font-size
is in your property blackList but you want to transform this property specifically.var gulp = require('gulp');
var postcss = require('gulp-postcss');
var px2vw = require('postcss-pixel-to-vw');
gulp.task('css', function () {
var processors = [
px2vw({
viewportWidth: 750
})
];
return gulp.src(['build/css/**/*.css'])
.pipe(postcss(processors))
.pipe(gulp.dest('build/css'));
});
v1.0.0
FAQs
A CSS post-processor that converts px to vw units.
The npm package postcss-pixel-to-vw receives a total of 0 weekly downloads. As such, postcss-pixel-to-vw popularity was classified as not popular.
We found that postcss-pixel-to-vw 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.