网页 综合 更新时间 2025-04-25 00:00:00

How to use Sass in Next.js

自动蜘蛛 nextjs.org 正文约 1048 字
How to use Sass in Next.js
Next.js has built-in support for integrating with Sass after the package is installed using both the .scss and .sass extensions. You can use component-level Sass via CSS Modules and the .module.scss or .module.sass extension.
First, install sass:
Sass supports two different syntaxes, each with their own extension. The .scss extension requires you use the SCSS syntax, while the .sass extension requires you use the Indented Syntax ("Sass").
If you're not sure which to choose, start with the .scss extension which is a superset of CSS, and doesn't require you learn the Indented Syntax ("Sass").
If you want to configure your Sass options, use sassOptions in next.config.
You can use the implementation property to specify the Sass implementation to use. By default, Next.js uses the sass package.
Next.js supports Sass variables exported from CSS Module files.
For example, using the exported primaryColor Sass variable:
Last updated April 25, 2025
Subscribe to our newsletter
Stay updated on new releases and features, guides, and case studies.
访问原文 返回搜索 https://nextjs.org/docs/pages/guides/sass
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。