
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
prefixify-css
Advanced tools
Reads a CSS file meant for 'global context' and prefixes each selector with a specified selector, wrapping the remainder in :global()
Reads a CSS file meant for 'global context' and prefixes each selector with a specified selector, wrapping the remainder in :global()
.SomeLibrary .wrapper {
width: 100%;
}
.SomeLibrary-blah li:nth-child(5) {
opacity: 0.5;
}
/* Becomes */
.myPrefix :global(.SomeLibrary .wrapper) {
width: 100%;
}
.myPrefix :global(.SomeLibrary-blah li:nth-child(5)) {
opacity: 0.5;
}
This is useful when using CSS Modules and you want to include something like CodeMirror, Leaflet and other libraries which has CSS which are globally scoped, but you want to at the very least contain it to within one of your classes.
As a CLI tool:
npm install -g prefixify-css
or, if you want to use it programatically:
npm install prefixify-css
$ prefixify
prefixify-css: Reads a CSS file meant for 'global context' and prefixes each selector with a specified selector, wrapping the remainder in :global()
The result is written to stdout.
Usage
$ prefixify <input> <selector>
Examples
$ prefixify leaflet.css '.leafletInput' > prefixed.css
$ prefixify - '.leafletInput' < cat /path/to/leaflet.css
Alternatively, you can run it through npx
without even having to install it:
$ npx prefixify-css myFile.css .mySelector
const prefixify = require('prefixify-css')
prefix({
content: '.CodeMirror { width: 100%; }',
selector: '.myClass',
})
.then((result) => {
// .myClass :global(.CodeMirror) { width: 100%; }
console.log(result)
})
.catch((error) => {
console.error(error)
})
MIT © Espen Hovlandsdal
FAQs
Reads a CSS file meant for 'global context' and prefixes each selector with a specified selector, wrapping the remainder in :global()
The npm package prefixify-css receives a total of 6 weekly downloads. As such, prefixify-css popularity was classified as not popular.
We found that prefixify-css 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.