Skip to content
Latchkey

Sass "legacy JS API is deprecated" in CI

Dart Sass deprecated the legacy render/renderSync JavaScript API in favor of compile/compileString. Bundlers or wrappers still calling the old API print this warning, which strict CI can fail on.

What this error means

The build logs "Deprecation Warning [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0." from a loader or build tool.

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

A loader still uses the legacy API

An older sass-loader or build integration calls renderSync, which is the deprecated path under current dart-sass.

A pinned modern sass with an old consumer

Upgrading sass while keeping an old loader means the new package warns about the old API the loader uses.

How to fix it

Upgrade the consumer to the modern API

  1. Upgrade sass-loader (or the wrapper) to a version that uses the modern compile API.
  2. Set the loader to the modern API if it offers an option.
  3. Rebuild and confirm the warning is gone.
Terminal
npm install --save-dev sass-loader@latest sass@latest

Select the modern API explicitly

If your loader exposes an api option, set it to modern so it stops calling the legacy entry point.

webpack.config.js
// webpack sass-loader options
{ loader: 'sass-loader', options: { api: 'modern' } }

How to prevent it

  • Keep sass and its loader on versions that use the modern API.
  • Set the loader api option to modern where available.
  • Compile Sass in CI so deprecation warnings are visible before removal.

Related guides

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