在 webpack 中使用 Lightning CSS 的实验性支持。Lightning CSS 是一个用 Rust 编写的快速 CSS 转换器和压缩器。
如果未设置此选项,webpack 上的 Next.js 默认使用 PostCSS 和 postcss-preset-env。
从 Next 14.2 开始,Turbopack 默认使用 Lightning CSS。此配置选项对 Turbopack 无效。Turbopack 始终使用 Lightning CSS。
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
useLightningcss: false, // default, ignored on Turbopack
},
}
export default nextConfig/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
useLightningcss: true, // disables PostCSS on webpack
},
}
module.exports = nextConfig| 版本 | 变更 |
|---|---|
15.1.0 | 从 Turbopack 中移除了对 useSwcCss 的支持。 |
14.2.0 | Turbopack 的默认 CSS 处理器从 @swc/css 更改为 Lightning CSS。useLightningcss 在 Turbopack 上被忽略,并添加了一个遗留的 experimental.turbo.useSwcCss 选项。 |