
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-dynamic-css-plugin
Advanced tools
Webpack plugin to transform dynamic react class names to short prefixed and obfuscated classes at runtime
Webpack plugin to transform dynamic react class names to short prefixed and obfuscated classes at runtime
Format to add a prefix and obfuscate the class names:
"pf_[md4:hash:base64:5]";
The dynamic nature means that runtime generated classes get transformed
Input:
<MyComponent className={["my-component", `is-disabled_${disabled}`].join()} />
Evaluated:
<MyComponent className={"my-component is-disabled_true"} />
Output:
<div class="pf_Xscyf pf_LfRuA"></div>
.pf_Xscyf.pf_LfRuA {
//Styles
}
npm install react-dynamic-css-plugin --save-dev
webpack.config.js
const path = require("path");
const ReactDynamicCssPlugin = require("react-dynamic-css-plugin");
module.exports = {
target: "web",
entry: {
main: "./src/index.jsx"
},
output: {
path: path.join(__dirname, "build"),
filename: `js/[name].min.js`,
chunkFilename: "js/[name].min.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
resolve: {
extensions: [".js", ".jsx"]
},
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}
},
{
test: /\.(css)$/,
use: [
{
loader: "css-loader"
}
]
}
]
},
plugins: [
new ReactDynamicCssPlugin({
enabled: true,
entryName: "main",
localIdentName: "myPrefix_[md4:hash:base64:5]",
attributes: /^(class)$/,
exclusionTags: /(path)/i,
exclusionValues: /^(css|sc|icon)-/i,
scope: ""
})
]
};
Note: The exclusionValues default excludes class names with the following prefixes. This is because they are commonly generated by other libraries and should not be transformed.
FAQs
Webpack plugin to transform dynamic react class names to short prefixed and obfuscated classes at runtime
We found that react-dynamic-css-plugin 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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.