
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
postcss-unit-processor
Advanced tools
PostCSS plugin to process css unit.
$ npm install postcss postcss-unit-processor --save-dev
Use the processor function provided by the user to process the CSS unit. The default processor function is not to do any processing.
// input
h1 {
margin: 0 0 20px;
font-size: 32px;
line-height: 1.2;
letter-spacing: 1px;
}
// output
h1 {
margin: 0 0 20px;
font-size: 32px;
line-height: 1.2;
letter-spacing: 1px;
}
var fs = require('fs');
var postcss = require('postcss');
var unitProcessor = require('postcss-unit-processor');
var css = fs.readFileSync('main.css', 'utf8');
var options = {
processor: (value, unit) => {
if (unit === 'px') {
return value / 2;
}
}
};
var processedCss = postcss(unitProcessor(options)).process(css).css;
fs.writeFile('main-new.css', processedCss, function (err) {
if (err) {
throw err;
}
console.log('New file written.');
});
Type: Object | Null
Default:
{
processor: (value) => value,
unitPrecision: 5,
propList: ['*'],
selectorBlackList: [],
replace: true,
mediaQuery: false,
exclude: /node_modules/i
}
processor
(Function) css unit processing function.
value
of the object replaces the value, and the unit
replaces the name.unitPrecision
(Number) The decimal numbers to allow the processed units to grow to.propList
(Array) The properties that can be changed by the processor function.
*
to enable all properties. Example: ['*']
*
at the start or end of a word. (['*position*']
will match background-position-y
)!
to not match a property. Example: ['*', '!letter-spacing']
['*', '!font*']
selectorBlackList
(Array) The selectors to ignore.
['body']
will match .body-class
[/^body$/]
will match body
but not .body
replace
(Boolean) Replace rules instead of adding fallbacks.mediaQuery
(Boolean) Allow processor function in media queries.exclude
(String, Regexp, Function) The file path to ignore.
'exclude'
will match \project\postcss-unit-processor\exclude\path
/exclude/i
will match \project\postcss-unit-processor\exclude\path
function (file) { return file.indexOf('exclude') !== -1; }
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var unitProcessor = require('postcss-unit-processor');
gulp.task('css', function () {
var processors = [
autoprefixer({
browsers: 'last 1 version'
}),
unitProcessor({
processor: (value, unit) => {
if (unit === 'px') {
return value / 2;
}
}
})
];
return gulp.src(['build/css/**/*.css'])
.pipe(postcss(processors))
.pipe(gulp.dest('build/css'));
});
FAQs
PostCSS plugin to process css unit.
The npm package postcss-unit-processor receives a total of 2 weekly downloads. As such, postcss-unit-processor popularity was classified as not popular.
We found that postcss-unit-processor 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 MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.