Skip to content

sassOptions

sassOptions 允许你配置 Sass 编译器。

¥sassOptions allow you to configure the Sass compiler.

ts
import type { NextConfig } from 'next'

const sassOptions = {
  additionalData: `
    $var: red;
  `,
}

const nextConfig: NextConfig = {
  sassOptions: {
    ...sassOptions,
    implementation: 'sass-embedded',
  },
}

export default nextConfig

需要了解:

¥Good to know:

  • sassOptions 不在 implementation 之外输入,因为 Next.js 不维护其他可能的属性。

    ¥sassOptions are not typed outside of implementation because Next.js does not maintain the other possible properties.

  • 用于定义自定义 Sass 函数的 functions 属性仅在 webpack 中受支持。使用 Turbopack 时,自定义 Sass 函数不可用,因为 Turbopack 基于 Rust 的架构无法直接执行通过此选项传递的 JavaScript 函数。

    ¥The functions property for defining custom Sass functions is only supported with webpack. When using Turbopack, custom Sass functions are not available because Turbopack's Rust-based architecture cannot directly execute JavaScript functions passed through this option.