sassgulpgulp-sass

How to Silence Deprecation Warning in Gulp Sass Task - "The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0."


My current installation is the follow:

Node - v20.18.0 Gulp - v5.0.0 Gulp-Sass - v5.1.0 Sass - v1.80.6

My gulpfile.js:

const gulp = require("gulp");
const sass = require("gulp-sass")(require("sass"));
 
gulp.task("sass", function(){
  return gulp
    .src("./src/sass/*.scss")
    .pipe(sass())
    .pipe(gulp.dest("./dist/css"));
});

Running "gulp sass" completes the task successfully, however it issues two deprecation warnings, one for each scss file processed:

❯ gulp sass
[13:05:58] Using gulpfile ~\Dev\Udemy\Gulp4\Section2\gulpfile.js
[13:05:58] Starting 'sass'...
Deprecation Warning: 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
 
Deprecation Warning: 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
 
[13:05:58] Finished 'sass' after 87 ms

I thoroughly read the documentation of both gulp-sass and sass, however I'm unable to silence these deprecation warnings by setting "silenceDeprecations" to the correct value in the gulpfile.js. It's a pain to have to scroll through these warnings when process multiple scss files.

Does anyone have a working solution?


Solution

  • You can add an option silenceDeprecations to temporarily hide these warnings:

    const gulp = require("gulp");
    const sass = require("gulp-sass")(require("sass"));
     
    gulp.task("sass", function(){
      return gulp
        .src("./src/sass/*.scss")
        .pipe(sass({
          silenceDeprecations: ['legacy-js-api'],
        }))
        .pipe(gulp.dest("./dist/css"));
    });