Skip to content

Commit fb98eb0

Browse files
Merge pull request SharePoint#8732 from andrewconnell/new-sass-config
📜 add article on configuring SASS for spfx
2 parents df80d8f + 5a2702c commit fb98eb0

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

docs/spfx/toolchain/configure-sass.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Configure SASS processing during builds
3+
description: In this article, you'll learn how to configure the SASS processing during builds of your SharePoint Framework (SPFx) projects.
4+
ms.date: 01/27/2023
5+
ms.localizationpriority: high
6+
---
7+
8+
# Configure SASS processing during builds
9+
10+
In this article, you'll learn how to configure the SASS processing during builds of your SharePoint Framework (SPFx) projects.
11+
12+
## Updating the toolchain to use a modern SASS processor
13+
14+
The SPFx v1.15 changed the SASS processor the build toolchain used to transpile CSS files from the NPM package [node-sass](https://www.npmjs.com/package/node-sass) to [sass](https://www.npmjs.com/package/sass). The **sass** package is a pure JavaScript implementation of the now-deprecated **dart-sass** package.
15+
16+
This change was primarily made because the [**node-sass** package was deprecated back in 2018](https://sass-lang.com/blog/libsass-is-deprecated), but the **sass** package is also much faster than the **node-sass** package it replaced.
17+
18+
## Impacts of the change
19+
20+
However, changes in the CSS Language required developers to rethink of some of the SASS language paradigms to make it clearer for developers, what a CSS definition is, and what needs to processed by SASS.
21+
22+
When the SPFx toolchain was changed to use the new SASS processor, it required some changes to the SASS code in default SPFx projects as the new processor flagged some syntax errors to address some outdated SASS syntax. These changes introduced some deprecation warnings from the new SASS processor.
23+
24+
Other developers had already dealt with these same deprecation warnings in their projects by getting the SASS package maintainers to add capability to suppress warnings caused by dependencies.
25+
26+
In other words, they needed a way to silence warnings caused by dependencies you don’t own or code potentially that’s inside your SPFx web part. This also happens even to partial files in the same SPFx package.
27+
28+
However, because the **sass** package is added as part of the toolchain, it wasn't easy to configure the processor to silence these deprecations.
29+
30+
## How to silence deprecation warnings in the SASS processor
31+
32+
To address this, all SPFx projects starting with v1.16.1 now include a new file: **./config/sass.json**.
33+
34+
If you have deprecation warnings coming from SASS files you don't maintain in your project, and thus, you have no control over, you can add `"quietDeps": true` to this file to configure the **sass** processor to suppress all deprecation warnings.
35+
36+
```json
37+
{
38+
"$schema": "https://developer.microsoft.com/json-schemas/heft/sass.schema.json",
39+
"quietDeps": true
40+
}
41+
```
42+
43+
## See also
44+
45+
- [SharePoint Framework v1.16.1 release notes](../release-1.16.1.md)
46+
- [Stefan Bauer: What’s new with SASS in SPFx 1.16.0](https://n8d.at/whats-new-with-sass-in-spfx-1-16-0)\
47+
- [Andrew Connell: Unboxing the SharePoint Framework (SPFx) v1.16.1 release](https://www.voitanos.io/blog/sharepoint-framework-v1-16-1-whats-in-latest-update-of-spfx/)

docs/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@
428428
href: spfx/toolchain/sharepoint-framework-toolchain.md
429429
- name: Yeoman generator for the SharePoint Framework
430430
href: spfx/yeoman-generator-for-spfx-intro.md
431+
- name: Configure SASS processing during builds
432+
href: spfx/toolchain/configure-sass.md
431433
- name: Microsoft Graph Toolkit
432434
href: spfx/use-microsoft-graph-toolkit.md
433435
- name: Debugging
@@ -455,7 +457,7 @@
455457
- name: SharePoint 2019 & SE support
456458
href: spfx/sharepoint-2019-support.md
457459
- name: SharePoint 2016 support
458-
href: spfx/sharepoint-2016-support.md
460+
href: spfx/sharepoint-2016-support.md
459461
- name: Release notes & roadmap
460462
items:
461463
- name: Overview

0 commit comments

Comments
 (0)