Socket
Socket
Sign inDemoInstall

postcss-classname-obfuscator

Package Overview
Dependencies
4
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-classname-obfuscator

This PostCSS plugin replaces CSS class names with hard-to-guess characters.


Version published
Weekly downloads
9
decreased by-25%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

[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

Added

  • inputJson - JSON file that contains the class names to be

Readme

Source

postcss-classname-obfuscator

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);
}

Usage

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': {},
  },
};

Options

OptionTypeDefaultDescription
typestring"nextjs""nextjs" - Application-specific directories Only supported by Next.js
enablebooleantrueEnable or disable the obfuscation.
lengthnumber6Character length (max. 32 characters)length.
methodstring"random""random" or "none" obfuscation method for classes.
prefixstring""Prefix for custom properties.
suffixstring""Suffix for custom properties.
ignorestring[][]Array of custom properties to ignore.
outputstring""Obfuscated property list json file output destination
directorystring""Directory to replace obfuscated class names
[new] inputJsonstring""The json output by output is available.
ignoreRegexstring[][]Regex to ignore.
hashAlgorithmstring"sha256"Hash algorithm for obfuscation.
preRun() => Promise() => Promise.resolve()What to do before running the plugin
callBack() => voidfunction () {}Callback function to run after the plugin has finished running

License

This source code is released under the MIT license.

Keywords

FAQs

Last updated on 20 Feb 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc