Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minagishl/postcss-obfuscate-custom-properties
This PostCSS plugin replaces the names of custom properties with hard-to-guess characters
https://github.com/minagishl/postcss-obfuscate-custom-properties
Last synced: 2 months ago
JSON representation
This PostCSS plugin replaces the names of custom properties with hard-to-guess characters
- Host: GitHub
- URL: https://github.com/minagishl/postcss-obfuscate-custom-properties
- Owner: minagishl
- License: mit
- Created: 2023-12-08T20:32:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-30T14:13:32.000Z (6 months ago)
- Last Synced: 2024-10-06T04:11:32.306Z (3 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/postcss-obfuscate-custom-properties
- Size: 102 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# postcss-obfuscate-custom-properties
This plugin replaces the names of CSS custom properties with hard-to-guess strings.
```css
:root {
--primary: 240 5.9% 10%;
--secondary: 240 4.8% 95.9%;
}
``````css
:root {
--b6d946: 240 5.9% 10%;
--f02024: 240 4.8% 95.9%;
}
```## Usage
**Step 1:** Install plugin:
```bash
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:
```diff
module.exports = {
plugins: {
autoprefixer: {},
+ 'postcss-obfuscate-custom-properties': {},
},
};
```## Options
| Option | Type | Default | Description |
| -------------------- | ------------------- | ----------------------- | -------------------------------------------------------------- |
| 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 |
| speedPriority | boolean | false | Ignore all regular expressions and execute. |
| ignoreRegex | string[] | [] | Regex to ignore. |
| ignoreSelectors | string[] | [] | Array of selectors to ignore. |
| IgnoreSelectorsRegex | string[] | [] | Regex to ignore selectors. |
| [new] 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 |## License
This source code is released under the [MIT license.]
[MIT license.]: https://opensource.org/licenses/MIT
[official docs]: https://github.com/postcss/postcss#usage