Sass prints deprecation warnings for global functions when Vite compiles Bootstrap
Deprecation warning about the global abs() function when compiling Bootstrap SCSS with ViteShort 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.
Fix it fast
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 -402Match what you see, then jump to its fix
- 1
The stack in the warning points into node_modules/bootstrap/scssWarnings come from a dependency (Bootstrap), not from your codeFix - 2
You import Bootstrap's scss and want a clean build until Bootstrap moves to @useSilence one named deprecation on purposeFix - 3
The warning points at a file under src/Your own stylesheet uses global functions or @importFix
- 1
What does the error look like?
Deprecation warning about the global abs() function when compiling Bootstrap SCSS with ViteSass @import rules are deprecatedWarnings 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 -52Fix
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 buildConfirmed by sass-lang.com
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 | head2Fix
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 buildConfirmed by sass-lang.com
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 | head2Fix
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.scss3Verify
No warning that points into src remains.
npm run buildConfirmed by sass-lang.com
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 fixWeb apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Apollo Client is blocked by CORS when the GraphQL server runs on AWS Lambda
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Apollo Server does not set CORS for you when it runs behind a framework or integration, and on Lambda that layer is API Gateway.
5 causes, each with a fixWeb 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