Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
lightningcss
Advanced tools
LightningCSS is a high-performance CSS parser, transformer, and minifier. It is designed to handle large CSS files efficiently and provides various functionalities for CSS processing.
CSS Parsing
This feature allows you to parse CSS strings into an Abstract Syntax Tree (AST). The code sample demonstrates how to parse a simple CSS string and log the resulting AST.
const { parse } = require('lightningcss');
const css = '.class { color: red; }';
const ast = parse(css);
console.log(ast);
CSS Minification
This feature enables you to minify CSS code, reducing its size for better performance. The code sample shows how to minify a CSS string and log the minified output.
const { minify } = require('lightningcss');
const css = '.class { color: red; }';
const minified = minify(css);
console.log(minified);
CSS Transformation
This feature allows you to transform CSS code based on specific targets, such as browser compatibility. The code sample demonstrates transforming a CSS string to be compatible with the specified browser targets.
const { transform } = require('lightningcss');
const css = '.class { color: red; }';
const transformed = transform(css, { targets: { browsers: ['> 1%', 'last 2 versions'] } });
console.log(transformed);
PostCSS is a tool for transforming CSS with JavaScript plugins. It is highly extensible and can be used for a wide range of CSS processing tasks, including parsing, minification, and transformation. Compared to LightningCSS, PostCSS offers a more extensive plugin ecosystem but may not be as performant for large CSS files.
Clean-CSS is a fast and efficient CSS minifier. It focuses primarily on minification and optimization of CSS files. While it is highly effective for reducing file size, it does not offer the same level of parsing and transformation capabilities as LightningCSS.
CSSO (CSS Optimizer) is a CSS minifier that also provides structural optimizations. It is designed to reduce the size of CSS files while preserving their functionality. CSSO is similar to LightningCSS in terms of minification but may not offer as comprehensive parsing and transformation features.
An extremely fast CSS parser, transformer, and minifier written in Rust. Use it with Parcel, as a standalone library or CLI, or via a plugin with any other tool.
calc()
expressions where possible.color-mix()
functionlab(from purple calc(l * .8) a b)
lab()
, lch()
, oklab()
, and oklch()
colorscolor()
function supporting predefined color spaces such as display-p3
and xyz
rgb
and hsl
functionshwb()
color syntax#rgba
and #rrggbbaa
hex colors:not
with multiple arguments:lang
with multiple arguments:dir
:is
red 40% 80%
)clamp()
, round()
, rem()
, and mod()
math functionsplace-items
)overflow
shorthand@media (width <= 100px)
or @media (100px < width < 500px)
)display
property (e.g. inline flex
)system-ui
font family fallbacks@keyframes
names, grid lines/areas, @counter-style
names, etc.:local()
and :global()
selectorscomposes
propertyLightning CSS can be used from Parcel, as a standalone library from JavaScript or Rust, using a standalone CLI, or wrapped as a plugin within any other tool. See the Lightning CSS website for documentation.
$ node bench.js bootstrap-4.css
cssnano: 544.809ms
159636 bytes
esbuild: 17.199ms
160332 bytes
lightningcss: 4.16ms
143091 bytes
$ node bench.js animate.css
cssnano: 283.105ms
71723 bytes
esbuild: 11.858ms
72183 bytes
lightningcss: 1.973ms
23666 bytes
$ node bench.js tailwind.css
cssnano: 2.198s
1925626 bytes
esbuild: 107.668ms
1961642 bytes
lightningcss: 43.368ms
1824130 bytes
For more benchmarks comparing more tools and input, see here. Note that some of the tools shown perform unsafe optimizations that may change the behavior of the original CSS in favor of smaller file size. Lightning CSS does not do this – the output CSS should always behave identically to the input. Keep this in mind when comparing file sizes between tools.
FAQs
A CSS parser, transformer, and minifier written in Rust
The npm package lightningcss receives a total of 1,234,660 weekly downloads. As such, lightningcss popularity was classified as popular.
We found that lightningcss 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.