LightningCSS: High-Performance CSS Toolchain for Linux ARM

1.32.0 · active · verified Tue Apr 21

LightningCSS is an extremely fast CSS parser, transformer, minifier, and bundler written in Rust, designed for high-performance frontend build processes. The package `lightningcss-linux-arm-gnueabihf` specifically provides the native binary for ARMv7 Linux systems, enabling the core `lightningcss` library to execute its high-performance Rust logic on this architecture. The current stable version is 1.32.0, with frequent minor and patch releases. A key differentiator is its speed, often being over 100x faster than comparable JavaScript-based tools, capable of minifying millions of lines of code per second. It supports modern CSS features like nesting, container queries, view transitions, high gamut color spaces, and custom media queries, automatically transpiling them for specified browser targets using Browserslist configuration.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use LightningCSS to parse, minify, and transpile modern CSS syntax (like nesting, custom media queries, and OKLAB colors) for specified browser targets, including source map generation.

import { transform, browserslistToTargets } from 'lightningcss';
import browserslist from 'browserslist';
import { Buffer } from 'node:buffer';

const cssInput = `
  @media (width <= 600px) {
    .card {
      display: grid;
      gap: 1rem;
      color: oklab(59.686% 0.1009 0.1192);
      @nest &::before {
        content: 'Mobile view';
      }
    }
  }
  .container { width: clamp(200px, 50%, 800px); }
`;

// Define browser targets using browserslist
const targets = browserslistToTargets(browserslist('last 2 versions, > 0.2%'));

try {
  const { code, map } = transform({
    filename: 'input.css',
    code: Buffer.from(cssInput),
    minify: true,
    sourceMap: true,
    targets,
    drafts: {
      nesting: true,
      customMedia: true
    }
  });

  console.log('Transformed and minified CSS:\n', code.toString());
  // console.log('Source Map:\n', map?.toString());

  // Example for bundling (requires a file on disk)
  // import { bundle } from 'lightningcss';
  // const { code: bundledCode } = bundle({
  //   filename: 'path/to/entry.css',
  //   minify: true,
  //   targets,
  // });
  // console.log('Bundled CSS:\n', bundledCode.toString());

} catch (error) {
  console.error('Error transforming CSS:', error);
}

view raw JSON →