sassgulpgulp-sass

Gulp-sass 5.0 how to use compiler with import() instead of require()?


Gulp-sass recently updated to version 5.0. They describe that it doesn't include a compiler anymore and they say you have to install in separately.

They have documentation on how to let gulp-sass require the compiler with this piece of code.

var sass = require('gulp-sass')(require('sass'));

But im using import() instead of require() and i can't find out how to translate the code they provided with require() to import().

This is also the error i get:

Error in plugin "gulp-sass"
Message:

gulp-sass 5 does not have a default Sass compiler; please set one yourself. 
Both the `sass` and `node-sass` packages are permitted.
For example, in your gulpfile:

  var sass = require('gulp-sass')(require('sass'));

For now i rolled back to version 4.1.1 which included the compiler but i would like to update it to version 5.0 at some point.


Solution

  • import gulpSass from "gulp-sass";
    import nodeSass from "node-sass";
        
    const sass = gulpSass(nodeSass);
    

    Try this. But I still don't know if this is the best.