![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
postcss-secmodify
Advanced tools
A PostCSS plugin that allows you to target individual sections of your CSS and modify them. (So you can pretend it's not a hacky fix)
Use this plugin to:
Installation | Usage | Getting it Working | Quirks |
---|
postcss-secmodify
is compatible with PostCSS v4.1+.
npm install postcss-secmodify --save
The config object for this tool controls everything, secModify looks at the keys 'sel', 'dec', 'decVal', 'atRule', 'media', 'selInMedia', 'decInMedia', 'decValInMedia', atRuleInMedia', and 'rString':
var secMConfig = {
// sel: [],
// dec: [],
// decVal: [],
// atRule: [],
// media: [],
// selInMedia: [],
// decInMedia: [],
// decValInMedia: [],
// atRuleInMedia: [],
rString: ''
};
rString's value is a string or function that will be used when replacing (aka: the new stuff that gets put in) and is the only mandatory key and value. It can be an empty string of course, if you feel like removing stuff. It can also use the $
patterns to manipulate what is inserted, or, by inserting a function to use you can do much more than simple replacing.
Everything but 'rString' takes in what will be used to match in it's particular section of the css
.foo
) outside of @media
blocks,color
) outside of @media
blocks,blue
) outside of @media
blocks,screen
in @special screen {
) outside of @media
blocks,@media
statements,@media
statements... I think you get the picture
All the these 'matcher' keys can be strings, RegEx objects, or arrays of strings and/or RegEx objects. They are also (as you might have guessed) completely optional, and can be excluded from the object. Secmodify is based off of string.replace() and inherits it's behavior. For example, an inputted string (to match) will only match and replace the first thing it finds.
There is a mandatory 'config object' that must be passed in. For example (as a node script):
var fs = require('fs');
var postcss = require('postcss');
var secModify = require('postcss-secmodify');
var inputCss = fs.readFileSync('input.css', 'utf8');
var secMConfig = {
sel: '.foo',
dec: [new RegExp(/-\d[abcd]-/g), new RegExp(/-\d+-/g)],
// atRule: [],
media: new RegExp(/-\w\w-/g),
selInMedia: ['stuff', 'things', 'otherStuff'],
// decInMedia: [],
// decValInMedia: [],
// atRuleInMedia: [],
rString: 'something_else'
};
var outputCss = postcss()
.use(secModify(secMConfig))
.process(inputCss)
.css;
console.log(outputCss);
Any part of the config object not declared (besides the rString key) will speed up execution because the things it applies to will not be looked at.
Or instead of doing this directly, you can take advantage of any of the myriad of other ways to consume PostCSS, and follow the plugin instructions they provide.
As with any piece of code it's got a few quirks. Behaviors that are not intended, and not enforced, and may disappear (or be forcibly altered) with the next release, so it's useful to be aware of them.
Order of Processing : It should evaluate top-to-bottom, and in the order of 'sel', 'dec', 'decVal', 'atRule', 'media', 'selInMedia', 'decInMedia', 'decValInMedia', 'atRuleInMedia'. So, more or less specificity-inclined.
Developer's thoughts "Don't get me wrong, this is probably quite niche, but whatever, here it is anyway."
FAQs
Sectional modification of css by RegEx or Strings.
The npm package postcss-secmodify receives a total of 99 weekly downloads. As such, postcss-secmodify popularity was classified as not popular.
We found that postcss-secmodify 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.