lightningcss-loader is a Webpack loader and minifier plugin that integrates the high-performance `lightningcss` engine into the Webpack build process. It provides a fast alternative for CSS processing, including features like prefixing, transpilation, and minification. The current stable version is `3.0.1`, with releases occurring regularly, including major updates that align with `lightningcss` capabilities. A key differentiator is its ability to replace functionality commonly provided by `postcss-loader` (specifically `autoprefixer` and `postcss-preset-env`) due to `lightningcss`'s built-in capabilities, leading to potentially significant build time improvements. It also offers a dedicated `LightningCssMinifyPlugin` for `optimization.minimizer` in Webpack 5.
npm install lightningcss-loaderVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure `LightningCssMinifyPlugin` in Webpack 5's `optimization` section for efficient CSS minification, including passing the `lightningcss` implementation.
Remove `parcel-css-loader` and `@parcel/css`, then install `lightningcss-loader` and `lightningcss`. Update all references in `webpack.config.js` and `package.json`.
Isolate `@custom-media` definitions into dedicated CSS files that contain only these custom media queries to avoid duplication.
Ensure `browserslist` is configured in your `package.json` or a separate config file. Upgrade to `lightningcss-loader@^2.1.0` or newer to get the fix for this issue.
Install `lightningcss` separately via `npm install lightningcss` or `pnpm add lightningcss`. Ensure it's imported as a default export: `const LightningCSS = require('lightningcss')` or `import LightningCSS from 'lightningcss'`.Uninstall `parcel-css-loader` and install `lightningcss-loader`. Update all references in `webpack.config.js` and `package.json`.
Ensure `LightningCssMinifyPlugin` is correctly imported as a named export from `lightningcss-loader` and used as `new LightningCssMinifyPlugin()` in your Webpack 5 configuration.
Provide a `browserslist` configuration in your `package.json` or a dedicated file (e.g., `.browserslistrc`). If using an older version of the loader, upgrade to `lightningcss-loader@^2.1.0` or newer.
Install `lightningcss` (`npm install lightningcss`) and ensure it's passed as a default export, e.g., `new LightningCssMinifyPlugin({ implementation: require('lightningcss') })`.