1.2.0 • Published 4 months ago

postcss-obfuscate-custom-properties v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

postcss-obfuscate-custom-properties

This plugin replaces the names of CSS custom properties with hard-to-guess strings.

:root {
  --primary: 240 5.9% 10%;
  --secondary: 240 4.8% 95.9%;
}
:root {
  --b6d946: 240 5.9% 10%;
  --f02024: 240 4.8% 95.9%;
}

Usage

Step 1: Install plugin:

npm  install  --save-dev  postcss  postcss-obfuscate-custom-properties

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: {
+       'postcss-obfuscate-custom-properties': {},
		autoprefixer: {}
	},
};

Options

OptionTypeDefaultDescription
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
speedPrioritybooleanfalseIgnore all regular expressions and execute.
ignoreRegexstring[][]Regex to ignore.
ignoreSelectorsstring[][]Array of selectors to ignore.
IgnoreSelectorsRegexstring[][]Regex to ignore selectors.
new 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.

1.2.0

4 months ago

1.1.0

5 months ago

1.0.0

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago