🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-lightningcss

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-lightningcss

PostCSS plugin to use lightningcss

0.6.0
Source
npm
Version published
Weekly downloads
9.5K
10.08%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-lightningcss

This PostCSS plugin uses lightningcss to compile and minify your CSS.

lightningcss is more than a minifier as it can replace quite a few PostCSS plugins such as autoprefixer. You can find the complete list of features in the package's documentation and the list of plugins it's able to replace below.

Install

yarn add -D postcss-lightningcss

Usage

const postcss = require("postcss");
const postcssLightningcss = require("postcss-lightningcss");

postcss([postcssLightningcss(/* pluginOptions */)]).process(
  YOUR_CSS /*, processOptions */
);

Options

const postcssLightningcss = require("postcss-lightningcss");

postcssLightningcss({
  // Use a browserslist query that will inform which browsers are supported
  // Will add or remove vendor prefixes that are needed or not anymore
  browsers: ">= .25%",
  // Will pass all options to lightningcss
  // Check out their documentation for details:
  // https://www.npmjs.com/package/lightningcss#user-content-documentation
  lightningcssOptions: {
    // Enable minification (default: true)
    minify: true,

    // Enable source maps (default: true)
    sourceMap: true,

    // Compile as cssModules (default: undefined)
    cssModules: false,

    // For which browsers to compile (default: undefined)
    // Can be omitted if you set the `browsers` option
    targets: {
      safari: (13 << 16) | (2 << 8), // represents Safari 13.2.0
    },

    // Individually enable various drafts
    drafts: {
      // Enable css nesting (default: undefined)
      nesting: false,
    },
  },
});

The detailed list of lightningcssOptions can be found here

About source maps

Source maps will pass through lightningcss. But many mappings will be lost in translation; lightningcss creates only a source map for selectors. Mappings for properties cannot be re-created after this transformation.

PostCSS plugins that you can remove if you have lightningcss

The rows marked as "Depends on browser config" will convert your CSS only if:

  • You set the browsers or lightningcssOptions.targets options
  • one of the target browsers doesn't support the feature
PostCSS Pluginlightningcss option
autoprefixerDepends on browser config
postcss-clampDepends on browser config
postcss-color-hex-alphaDepends on browser config
postcss-color-hslDepends on browser config
postcss-color-rgbDepends on browser config
postcss-color-functionDepends on browser config
postcss-color-rebeccapurpleDepends on browser config
postcss-custom-medialightningcssOptions.drafts.customMedia
postcss-double-position-gradientsDepends on browser config
postcss-hwb-functionDepends on browser config
postcss-lab-functionDepends on browser config
postcss-logicalDepends on browser config (1)
postcss-media-minmaxDepends on browser config
postcss-multi-value-displayDepends on browser config
postcss-nestinglightningcssOptions.drafts.nesting
postcss-normalize-display-valuesDepends on browser config
postcss-oklab-functionDepends on browser config
postcss-overflow-shorthandDepends on browser config
postcss-placeDepends on browser config
postcss-progressive-custom-propertiesDepends on browser config (2)
  • lightningcss doesn't support the logical shorthand keyword as its syntax is likely to change
  • Progressive custom properties works only if the properties don't contain properties themselves:
  • lab(29.2345% 39.3825 20.0664) has a proper fallback
  • oklch(40% 0.234 0.39 / var(--opacity-50)) will not have a fallback

License

MIT

Keywords

css

FAQs

Package last updated on 13 Sep 2022

Did you know?

Socket

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.

Install

Related posts