Skip to content

Migrate Sass @import to @use#1497

Open
MalpenZibo wants to merge 2 commits intomasterfrom
fix/sass-deprecation-warnings
Open

Migrate Sass @import to @use#1497
MalpenZibo wants to merge 2 commits intomasterfrom
fix/sass-deprecation-warnings

Conversation

@MalpenZibo
Copy link
Copy Markdown
Member

@MalpenZibo MalpenZibo commented Apr 29, 2026

Summary

Silences all Sass deprecation warnings emitted by both the library's own builds and consumers (e.g. gdsm's Vite + Dart Sass).

  • @import rule deprecation: replaced internal @import with @use ... as * across src/**/*.scss (plain CSS @import for .css files left in place — not deprecated).
  • slash-div deprecation: migrated $x / 2 to math.div($x, 2) in AsyncStatusIndicator, LoadingSpinner, ScrollView, Toggle.
  • darken() deprecation: migrated to color.adjust($c, $lightness: -10%) in Dropdown.
  • legacy-js-api deprecation (styleguide build): bumped sass-loader to ^16 and configured webpack with api: 'modern'.
  • Build switch: replaced node-sass (libsass — does not implement @use) with Dart Sass for the package's own npm run build. Dropped the now-unneeded sass-importer.js; bare specifiers are resolved via --load-path=node_modules, which works for both this build and consumer bundlers (Vite, sass-loader 10+).

Test plan

  • npm run build — clean, zero deprecation warnings.
  • npm run build-styleguidist — clean, zero warnings.
  • npm run typecheck passes.
  • npm run prettier-check passes.
  • Pre-existing snapshot test failures on master are unrelated to this change.

Sass `@import` rules are deprecated and will be removed in Dart Sass
3.0.0. Consumers compiling these stylesheets with Dart Sass were seeing
the deprecation warnings flood their build logs.

This migrates all internal @import rules to the modern @use module
system. Plain CSS @import rules (for .css files) remain since they are
not deprecated.

The legacy node-sass build is replaced with Dart Sass since libsass
does not implement @use. The custom sass-importer.js used to strip the
webpack-style `~` prefix is no longer needed because we switched to
bare specifiers resolved via `--load-path=node_modules`, which works
both for our own build and for consumer bundlers (Vite, sass-loader 10+).
- Replace `$x / 2` with `math.div($x, 2)` (asyncStatusIndicator,
  loadingSpinner, scrollView, toggle).
- Replace `darken($c, 10%)` with `color.adjust($c, $lightness: -10%)`
  in Dropdown.
- Bump sass-loader to ^16 and configure webpack with `api: 'modern'`
  so the styleguide build no longer hits the legacy JS API warning.
@pedrodim
Copy link
Copy Markdown
Member

Puoi generare una diff tra CSS prima e dopo come artifact per assicurarci che sia okay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants