Skip to content
Latchkey

Sass "legacy JS API" Deprecation - Fix in CI

Dart Sass deprecated the legacy render/renderSync JS API in favor of compile/compileString. When a build runs warnings-as-errors, the deprecation notice fails CI.

What this error means

The build prints Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0 and, under strict settings, exits non-zero.

sass
Deprecation Warning [legacy-js-api]: The legacy JS API is deprecated and
will be removed in Dart Sass 2.0.0.

More info: https://sass-lang.com/d/legacy-js-api

Common causes

Old sass-loader pinning the legacy API

sass-loader before v14 calls the deprecated render API. The warning surfaces through the loader, not your code.

Direct render()/renderSync() usage

A custom build script calls sass.render() instead of the modern sass.compile().

How to fix it

Upgrade sass-loader and select the modern API

  1. Upgrade sass-loader to a version that defaults to the modern API.
  2. Set api: 'modern' explicitly if needed.
webpack.config.js
// webpack.config.js (sass-loader options)
{ loader: 'sass-loader', options: { api: 'modern', implementation: require('sass') } }

Migrate custom scripts to compile()

  1. Replace render/renderSync with compile/compileString.
build.js
const sass = require('sass');
const result = sass.compile('src/styles/main.scss');
fs.writeFileSync('dist/main.css', result.css);

How to prevent it

  • Track Sass deprecation channels and migrate before the 2.0 removal.
  • Keep sass-loader and sass on supported, compatible versions.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →