
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
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.
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.');
});
// Only process rem units
unitProcessor({
processor: (value, unit) => value,
unitList: ['rem']
})
// Process all units except rem
unitProcessor({
processor: (value, unit) => value,
unitList: ['!rem']
})
// Process only rem and px units
unitProcessor({
processor: (value, unit) => value,
unitList: ['rem', 'px']
})
Type: Object | Null
Default:
{
processor: (value) => value,
unitPrecision: 5,
propList: ['*'],
unitList: ['*'],
selectorBlackList: [],
replace: true,
mediaQuery: false,
exclude: /node_modules/i,
customUnitList: []
}
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.unitList (Array) The units that can be changed by the processor function.
* to enable all units. Example: ['*']! to not match a unit. Example: ['*', '!rem']['rem', 'px', 'vw']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 .bodyreplace (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\pathfunction (file) { return file.indexOf('exclude') !== -1; }customUnitList (Array) List of custom units to process in addition to default units.
['dp', 'rpx']).px, rem, vw, etc.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'));
});
// input
h1 {
margin: 0 0 20px;
font-size: 32px;
line-height: 1.2;
letter-spacing: 1px;
}
// output
h1 {
margin: 0 0 10px;
font-size: 16px;
line-height: 1.2;
letter-spacing: 0.5px;
}
FAQs
PostCSS plugin to process css unit.
The npm package postcss-unit-processor receives a total of 2,454 weekly downloads. As such, postcss-unit-processor popularity was classified as popular.
We found that postcss-unit-processor demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.