
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
swc-plugin-css-modules
Advanced tools
A [SWC](https://swc.rs) plugin to use [CSS Modules](https://github.com/css-modules/css-modules).
A SWC plugin to use CSS Modules.
Instead of creating an object, the plugin injects the css class names directly into the js code. This allows to reduce the size of the bundle.
// Input Code
import styles from "./style.css";
element.innerHTML = '<div class="' + styles.className + '">';
// Output ↓ ↓ ↓ ↓ ↓ ↓
import "./style.css";
element.innerHTML = '<div class="' + "style__className___clZD5" + '">';
npm:
npm i -D swc-plugin-css-modules
yarn:
yarn add -D swc-plugin-css-modules
You can check the compatibility of versions on https://plugins.swc.rs/
Via .swcrc
{
"jsc": {
"experimental": {
"plugins": [
[
"swc-plugin-css-modules",
{
"generate_scoped_name": "[name]__[local]___[hash:base64:5]"
}
]
]
}
}
}
Using css modules in code:
import styles from "./style.module.css";
// ✅ ok
const className = styles.className;
// ✅ ok
const className = styles["class-name"];
// ⛔ Computed hit cannot be injected
const className = styles["class" + "Name"];
// ⛔ Computed hit cannot be injected
const className = styles[localClassName];
// ✅ ok
const className = classNames(styles.title, styles.className);
// ⛔ Computed hit cannot be injected
const className = getClassNameFromCssModules(styles);
generate_scoped_name
Default: "[hash:base64]"
Allows to configure the generated local ident name.
Supported template strings:
[name]
the basename of the resource[folder]
the folder the resource relative[ext]
- extension with leading[hash]
- the hash of the string(by default it's the hex
digest of the xxhash64
hash)[<hashFunction>:hash:<hashDigest>:<hashDigestLength>]
- hash with hash settings[local]
- original classSupported hash functions:
xxhash64
md4
md5
sha1
sha224
sha256
sha384
sha512
Supported hash digests:
hex
base32
base64
hash_prefix
Add custom hash prefix to generate more unique classes.
css_modules_suffix
Default: ".css"
root
If you need, you can pass any needed root path.
FAQs
A [SWC](https://swc.rs) plugin to use [CSS Modules](https://github.com/css-modules/css-modules).
The npm package swc-plugin-css-modules receives a total of 3,190 weekly downloads. As such, swc-plugin-css-modules popularity was classified as popular.
We found that swc-plugin-css-modules demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.