Fixing gulp-sass issues in gulp 4.
Tags: css, sass, gulpjs
Published: 2021-04-30 15:29:26

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3px8t6vpul6wzwicr4v.PNG)
Gulp is super cool - no doubt about that. This article is not the full definitive gulp article that I promised to post. This article is an important fix for gulp-sass in gulp 4.

I got to know about gulp while building a bootstrap blog template. While navigating the themes on [Bootstrap](https://themes.getbootstrap.com/), I got informed about a very important tool that web developers were using - That tool was gulp.
I started using gulp this year, and I've found a very superb tool in it. 
Gulp is so helpful especially with cool things like minifying and autoprefixing - Gulp does even more. 

While setting up gulp, I encountered some challenges. One of which was with the gulp-sass plugin.
Gulp-sass is a gulp plugin that enables developers to use sass through gulp. 

I believe that the same issues that I encountered with gulp-sass drove a lot of developers away from using gulp to other options like grunt.

Setting up gulp was kind of tedious for me since it was my first time using it. Anyway, things finally worked out. But then, not everything worked out fine as **"sass modules will not be processed"** - Somehow, gulp failed to process my sass modules.
Sass partials were not working. Both the **@use** and the **@import** rules failed to pull in a sass module.

After so many searches online - thanks to google, I found a stack overflow page that **"saved my gulp"**.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmpe344zkajf4942xj2t.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4v22thfhmaezplffwkn.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qn9axgefu0e005xwulrm.PNG)


Gulp seems not to have a good community base where releases and latest updates are published and discussed - maybe there is one I don't know of. But it took me days to finally figure out what was wrong with my gulp-sass plugin.

I made the following discoveries about gulp-sass. And with some more homework, I finally got my gulp working perfectly - at least as much as I know now. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kg7er46hy3q969cgh7qg.PNG)


1. Node-sass is the default compiler of sass inside of gulp. So if you fail to set the compiler to "sass" in your gulp.js script, Node-sass steps in as default. And sass will not be fully explored. Node-sass won't process sass completely, it seems outdated(deprecated). 
2. You need to set your sass compiler to "sass" (Dart-sass) to completely process sass inside of gulp. 
3. The docs on the NPM gulp-sass page need some important updating. 

With the above discoveries, I got my gulp well set up after making some changes. 

Here are some steps to getting your gulp-sass plugin well set in case you got stuck with it as I did.

1. Upgrade gulp-sass to the latest version if you have been using it(gulp-sass) for a long time.
2. Install [Dart-sass](https://sass-lang.com/dart-sass) by typing out the command below if you use NPM.

* "npm install --save-dev sass"

3. Update your gulp task as necessary.
4. Set your sass compiler to sass (Dart-sass)

* "sass.compiler = require('sass');"

Here is my own gulp tasks script. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxmlkdhk2rxa4wtlyo7s.PNG)

If properly executed, these few steps should help get your sass(gulp-sass) running well in gulp.

This article may not be as detailed enough for a total gulp beginner, But with some more hard work, even beginners should be able to get over their gulp-sass issues with the tips in this article.

I hope this article helps to get someone in the gulp-sass mess out as quickly as possible.

Cheers.