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.
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
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
- Upgrade sass-loader to a version that defaults to the modern API.
- Set
api: 'modern'explicitly if needed.
// webpack.config.js (sass-loader options)
{ loader: 'sass-loader', options: { api: 'modern', implementation: require('sass') } }Migrate custom scripts to compile()
- Replace
render/renderSyncwithcompile/compileString.
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.