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.
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-apiCommon 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
- Upgrade sass-loader (or the wrapper) to a version that uses the modern
compileAPI. - Set the loader to the modern API if it offers an option.
- Rebuild and confirm the warning is gone.
npm install --save-dev sass-loader@latest sass@latestSelect the modern API explicitly
If your loader exposes an api option, set it to modern so it stops calling the legacy entry point.
// 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
apioption to modern where available. - Compile Sass in CI so deprecation warnings are visible before removal.