
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.
🤷♂️ CSS-in-JS modules (via babel plugin):
Why create another CSS-in-JS library? Well, I tried hard to avoid doing it, but couldn't find one which does what I want. And I don't want much:
More on struggle finding existing solution here
npm i cssed
vite.config.js
:
import cssedVitePlugin from 'cssed/vite-plugin'
export default {
plugins: [
// ...
cssedVitePlugin()
// ...
]
}
No configuration required as long as you have enabled module:cssed
in your .babelrc
:
{
"plugins": ["module:cssed"]
}
Also, add compilation artifcats to gitignore
:
# cssed compilation artifacts
.cssed
import { css } from 'cssed'
import { dark, light } from './constants'
const styles = css`
.red {
color: red;
background: ${dark};
}
.blue {
color: blue;
background: ${light};
}
`
const Box = (props) => (
<div className={props.isRed ? styles.red : styles.blue}></div>
)
That's it? That's it.
Babel plugin during compilation will extract content of css
function call into a separate .module.css
file and will place it in .cssed
folder in the root of the project, rebasing URLs in css
.
Before:
// index.js – before compilation
import { css } from 'cssed'
const styles = css`
.red {
color: red;
}
`
const Box = (props) => <div className={styles.red}></div>
After compilation with cssed
:
// index.js – compiled with cssed
import _a from '../.cssed/[hash].module.css'
const styles = _a
const Box = (props) => <div className={styles.red}></div>
And file [hash].module.css
contains extracted css:
/* [hash].module.css */
/* AUTO GENERATED FILE. DO NOT EDIT */
.red {
color: red;
}
From here Webpack will handle it as a regular file, which has imported CSS and will process it accordingly to configured pipeline.
Same as for styled-jsx
package.
Launch VS Code Quick Open (⌘+P), paste the following command, and press enter.
ext install vscode-styled-jsx
Launch VS Code Quick Open (⌘+P), paste the following command, and press enter.
ext install vscode-styled-jsx-languageserver
check examples
for:
This would not be possible, without linaria. In fact inability to make it work in NextJS pushed me over the line to create cssed
🙃. They did awesome job making evaluators for template literals. So you can write expressions like these:
import { light } from './theme'
const cls = css`
.some {
color: ${light};
font-size: ${22 + 20};
}
`
Other notable projects:
atomic
layer to it, which is overkill for me. Also, syntax was not what I wanted:// this will not generate `cls.red` and `cls.blue` you would expect
const cls = css`
.red {
color: red;
}
.blue {
color: blue;
}
`
const Header = () => {
// This will not be styled. It's frustrating as hell.
const moreItems = (
<>
<div className={'item'}></div>
<div className={'item'}></div>
</>
)
return (
<>
<div className={'item'}></div>
{moreItems}
<style jsx>
{`
.item {
color: red;
}
`}
</style>
</>
)
}
css
api while what I need, didn't work in NextJS and also breaks when trying to use exported value like:import { dark } from '../theme'
// this will throw
const styles = css`
.red {
border: 2px solid ${dark};
padding: 10px;
}
`
CSSed is dead-simple CSS-in-JS implementation, without any gimmicks. Here is one if you need it:*
MIT
FAQs
🤷♂️CSS-in-JS modules that just works
The npm package cssed receives a total of 15 weekly downloads. As such, cssed popularity was classified as not popular.
We found that cssed 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.