Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
vite-plugin-replace-mangle-css-class
Advanced tools
Vite plugin to replace minified and obfuscated CSS classes at runtime.
The plugin will generate optimized class name in HTML and JavaScript. configure as follows:
import { defineConfig } from "vite";
import replaceMangleCSSClass from "vite-plugin-replace-mangle-css-class";
export default defineConfig({
plugins: [
replaceMangleCSSClass({
extensions: [".html", ".js", ".ts", ".vue", ".tsx", ".jsx"],
}),
],
});
This will replace class name matched regex in HTML and JavaScript files.
This plugin in html type files it looks for and obtains the html class
attribute and in javascript (others) files it also replaces strings like this: .{classname}
. For example:
In html
<!-- replace correctly -->
<!-- input -->
<div :class="{card: true}" class="card">
<div class="card-body"></div>
</div>
<!-- output -->
<div :class="{pkJ414a: true}" class="pkJ414a">
<div class="mki4Aak"></div>
</div>
But... in javascript:
// replace correctly
const el = document.querySelector(".card");
const el = document.querySelector(".pkJ414a");
// not replace correctly
const el = document.getElementsByClassName("card");
const el = document.getElementsByClassName("card");
const options = {
cwd: process.cwd(), // the current working directory
enabled: true, // enabled/disabled
extensions: [".html", ".js"], // files to find and replace obfuscated classes
JSONFile: "./.mangle-css-class/classes.json", // the json file of renamed CSS classes
exclude: [], // lists of all CSS classes to exclude
generateBundle(classNames) {}, // callback after completion of replacements
}
the current working directory
Enable/Disable the plugin
Files accepted for find and replace renamed css classes.
e.g.: [".html",".js"]
The JSON file containing all the renamed css classes. From this file you will get the CSS classes to find and replace. It must have the following structure:
{
"card":"pkJ414a",
"card-body":"mki4Aak"
}
List of all CSS classes that should not be replaced. Accepts values of type string or regex type.
e.g.: ["card", /card/gi]
A callback that is called after generating the bundle.
Source code
// css
.card {
}
.card-body {
}
<!-- html -->
<div class="card">
<div class="card-body"></div>
</div>
Output code
// css
.pkJ414a {
}
.mki4Aak {
}
<!-- html -->
<div class="pkJ414a">
<div class="mki4Aak"></div>
</div>
Dynamically generated css classes will not be replaced
We recommend using this vite plugin with postcss-mangle-css-class
This project is under license from MIT. For more details, see the LICENSE file.
Made with ❤️
FAQs
Vite plugin to replace minified and obfuscated CSS classes at runtime.
The npm package vite-plugin-replace-mangle-css-class receives a total of 1 weekly downloads. As such, vite-plugin-replace-mangle-css-class popularity was classified as not popular.
We found that vite-plugin-replace-mangle-css-class 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.