Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
postcss-classname-obfuscator
Advanced tools
Changelog
[1.2.0] - 2024-02-20
Added new inputJson
to address the issue of CSS not building correctly in web applications such as Next.js
inputJson
- JSON file that contains the class names to beReadme
This PostCSS plugin replaces CSS class names with hard-to-guess characters.
It may not work properly if the
.next
folder exists. Demo Site: https://postcss-classname-obfuscator-demo.vercel.app/
.primary {
color: var(--primary);
}
.secondary {
color: var(--secondary);
}
.b6d946 {
color: var(--primary);
}
.d6bdb8 {
color: var(--secondary);
}
Step 1: Install plugin:
npm install --save-dev postcss postcss-classname-obfuscator
Step 2: Check your project for existing PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
module.exports = {
plugins: {
autoprefixer: {},
+ 'postcss-classname-obfuscator': {},
},
};
Option | Type | Default | Description |
---|---|---|---|
type | string | "nextjs" | "nextjs" - Application-specific directories Only supported by Next.js |
enable | boolean | true | Enable or disable the obfuscation. |
length | number | 6 | Character length (max. 32 characters)length. |
method | string | "random" | "random" or "none" obfuscation method for classes. |
prefix | string | "" | Prefix for custom properties. |
suffix | string | "" | Suffix for custom properties. |
ignore | string[] | [] | Array of custom properties to ignore. |
output | string | "" | Obfuscated property list json file output destination |
directory | string | "" | Directory to replace obfuscated class names |
[new] inputJson | string | "" | The json output by output is available. |
ignoreRegex | string[] | [] | Regex to ignore. |
hashAlgorithm | string | "sha256" | Hash algorithm for obfuscation. |
preRun | () => Promise | () => Promise.resolve() | What to do before running the plugin |
callBack | () => void | function () {} | Callback function to run after the plugin has finished running |
This source code is released under the MIT license.
FAQs
This PostCSS plugin replaces CSS class names with hard-to-guess characters.
The npm package postcss-classname-obfuscator receives a total of 9 weekly downloads. As such, postcss-classname-obfuscator popularity was classified as not popular.
We found that postcss-classname-obfuscator 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.