Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Sass prints deprecation warnings for global functions when Vite compiles Bootstrap

ErrorDeprecation warning about the global abs() function when compiling Bootstrap SCSS with Vite

Short answer

Dart Sass deprecates global built-in functions such as abs() in favour of math.abs() from the module system, and @import in favour of @use. The warnings come from Bootstrap's own files, so you cannot edit them. Silence them for Vite with quietDeps or silenceDeprecations in css.preprocessorOptions.

  • Applies to Vite 7 and 8, sass-embedded 1.x, Bootstrap 5.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the warning: it names the stylesheet. If the path is inside node_modules/bootstrap, the code is not yours.

    npm run build 2>&1 | grep -i -A4 deprecat | head -40
  2. 2Match what you see, then jump to its fix

    1. 1The stack in the warning points into node_modules/bootstrap/scssWarnings come from a dependency (Bootstrap), not from your codeFix
    2. 2You import Bootstrap's scss and want a clean build until Bootstrap moves to @useSilence one named deprecation on purposeFix
    3. 3The warning points at a file under src/Your own stylesheet uses global functions or @importFix

What does the error look like?

  • Deprecation warning about the global abs() function when compiling Bootstrap SCSS with Vite
  • Sass @import rules are deprecated
  • Warnings about global built-in functions that name a stylesheet inside node_modules/bootstrap

Cause 1 of 3

Warnings come from a dependency (Bootstrap), not from your code

1Check

Sass has an option to hide warnings caused by dependencies while keeping them for your own stylesheets.

grep -rn "abs(" node_modules/bootstrap/scss | head -5

2Fix

Turn on quietDeps for scss in the Vite config. Vite passes css.preprocessorOptions to the Sass compiler.

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: { quietDeps: true },
    },
  },
})

3Verify

Rebuild: warnings that came from node_modules are gone, warnings from src still print.

npm run build

Confirmed by sass-lang.com

Did this fix it?

Cause 2 of 3

Silence one named deprecation on purpose

1Check

Global built-in functions and @import are separate deprecations: to silence both you must pass both, and the Sass docs name them import and global-builtin.

grep -rn "@import" src/**/*.scss | head

2Fix

List the deprecation ids in silenceDeprecations.

css: {
  preprocessorOptions: {
    scss: { silenceDeprecations: ['import', 'global-builtin'] },
  },
},

3Verify

The build output has no more warnings for those two ids.

npm run build

Confirmed by sass-lang.com

Did this fix it?

Cause 3 of 3

Your own stylesheet uses global functions or @import

1Check

The deprecation applies to your code too. The Sass docs say the module system replaces both, and a migrator converts a stylesheet.

grep -rn -E "@import|[^.]abs\(" src --include=*.scss | head

2Fix

Change @import to @use and call functions through their module, for example math.abs. The Sass migrator can do this for you.

npx sass-migrator module --migrate-deps src/styles/main.scss

3Verify

No warning that points into src remains.

npm run build

Confirmed by sass-lang.com

Did this fix it?

How do I stop it coming back?

  • Write new SCSS with @use and module functions such as math.abs.
  • Keep quietDeps on so dependency warnings do not bury your own.
  • Update Bootstrap when a release moves its Sass to the module system.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Web apps

A POST to a Google Apps Script web app returns 405 or a CORS error

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Apps Script web apps run doPost for POST and doGet for GET, and the Apps Script guides describe no other entry points.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.