gulp failed to compile the Sass file

I recently made the switch from using less to sass in my project. I went ahead and installed gulp-sass using npm and updated my gulpfile to compile sass instead of less. However, despite making these changes, gulp is not compiling my .scss file to css. I've tried researching and troubleshooting with no luck so far. Here are all the details I can provide:

gulpfile.js

// GULP CONFIG

// REQUIRES
    // general
    var gulp = require('gulp');
    // css
    var sass = require('gulp-sass');
    var minifycss = require('gulp-minify-css');
    var autoprefixer = require('gulp-autoprefixer');
    var rename = require("gulp-rename");
    // watch
    var watch = require('gulp-watch');


// TASKS
    // css 
    gulp.task('css', function() {
            gulp.src('style.css')                                       // get the 'all-import' css-file
            // .pipe(sass({includePaths: ['./styles']}))
            // .pipe(sass().on('error', sass.logError))                 
            .pipe(sass())                                               // sass to css
            .pipe(autoprefixer('last 2 version', { cascade: false }))   // autoprefix
            .pipe(minifycss())                                          // minify
            .pipe(rename('style.min.css'))                              // rename to style.min.css
            .pipe(gulp.dest(''));                                       // output to root
    });

    // watch
    gulp.task('watch', function() {
      gulp.watch('styles/*', ['css']); 
    });


// RUN DEFAULT
gulp.task('default', ['watch']);

related Folders & Files

├── style.min.css
├── style.css (with @import styles/style.scss)
│    └── styles
│          ├── style.scss

terminal response:

starting gulp:

[10:19:14] Starting 'watch'...
[10:19:14] Finished 'watch' after 11 ms
[10:19:14] Starting 'default'...
[10:19:14] Finished 'default' after 20 μs

after saving style.scss

[10:19:20] Starting 'css'...
[10:19:20] Finished 'css' after 15 ms

style.scss (content on purpose of testing obviously)

$color: #99cc00;

body {
  background-color: $color;
  .sub {
    color: $color;
  }
}

style.min.css after running through gulp

$color:#9c0;body{background-color:$color;.sub{color:$color}

Answer №1

Make sure to update your gulp watch task for sass files. The current line is looking for a css file:

gulp.src('style.css')

To fix this, change it to look for a scss file instead:

gulp.src('style.scss') // don't forget the 's'

Additionally, you need to specify an output destination. The following line lacks a destination:

.pipe(gulp.dest('')); 

Make sure to define where you want the compiled file to go. For example:

.pipe(gulp.dest('./')); // choose your desired route

Your file structure seems a bit unconventional. It might be beneficial to separate sass and compiled files into different folders.

Hopefully, these adjustments will lead you in the right direction.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Dynamic Theming in Ionic Framework

Currently, I am using Ionic in combination with Angular to create an App. I have introduced dynamic theming by adding two .scss files into my theme folder. In my app.scss file, I define the layout of components without colors, while all color styles are st ...

Top Method for Connecting Numerous Dependent HTTP Requests Without the Need for Multiple Subscriptions and Iterations

I'm working on an angular project where I have an API that creates a line item and then loops through to call the API for each modification before firing the print request. Currently, I am using multiple subscribes for this process and I was wondering ...

What are some effective strategies for optimizing the organization of express middlewares?

Currently, I have successfully implemented the following code using node and express. The code is located in file app.js app.use(function (req, res, next) { fs.mkdir('uploads/', function (e) { if (!!e && e.code !== 'EEX ...

Vue.js - dynamically applying CSS classes based on conditions

Within a VueNative project that utilizes NativeBase as a component library, with tags prefixed by nb-, the code snippet below is found within the <template> tags of the footer.vue file which houses navigation buttons. This piece of logic successfully ...

Re-posting a package that already exists leads to an Invalid Semantic Version error

My goal is to republish the package mssql version 10.0.0 as mssql-10 in order to have both versions coexist for incremental migration purposes over a prolonged period. After making changes only to the 'name' and 'description' attribute ...

What is the best way to incorporate classes into <li> elements within WordPress?

I'm currently in the process of building my WordPress theme from scratch, but I've run into a roadblock when it comes to adding custom classes to the < li > tags alongside those that are automatically generated by WordPress. Below is the co ...

I am experiencing some trouble with configuring the CoreUI Admin Template

I've encountered an issue where I've tried various methods to implement this theme but haven't had any success. 1. I followed the steps in the documentation by cloning the repo of the template and then using npm install (npm run serve) -> ...

Display of saved collection in Mongoose response

Currently, I am managing an Express application that interacts with a MongoDB through Mongoose. The main functionality involves a basic content management system that allows for updating values on specific pages. Strangely, when changes are made on my stag ...

The vs-tac module in the project's node_modules is missing for Visual Studio's Apache Cordova Tools

The vs-tac module is currently located in the directory "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\Packages\vs-tac", but it appears that it should be in the project ...

JavaScript utilizing an API to retrieve specific data values

Below is some API Data that I have: [ { "symbol": "AAPL", "name": "Apple Inc.", "price": 144.98, "changesPercentage": -1.22, "change": -1.79, ...

Is it necessary to only override the monospaced font?

Can the monospace font in Angular Material be customized for just the <code>foo</code> blocks? I want to use a font where the number zero 0 looks distinct from the letter oh O. ...

Ensuring the footer stays anchored at the bottom using Material-UI Expansion Drawers

Utilizing Material-UI@next in my React application, I have a component that showcases a list of items using Expansion Panels. Additionally, there is a straightforward <Footer /> component structured like this: import React, { Component } from "react ...

The carousel functionality in Firefox and Opera is currently experiencing issues and is not functioning properly

I have implemented a horizontal carousel at the bottom of my website www.woody.my. The carousel functions properly in Chrome, but is not visible in Firefox, Opera, and IE. Here is how it appears in Chrome: And this is how it looks in Firefox: ...

Master the Art of Image Loading in Codeigniter

Hey there, I'm completely new to Codeigniter. In the Controllers folder, I've created a file called caller.php and in the \Views directory, I've created a file named home1.php. Additionally, within the root directory, I've made an ...

Improving the method of verifying authorization for API requests with Express JS

I find that my server.js file is becoming overly redundant with repetitive code for checking client authorization on nearly every method belonging to the REST API. Each time an API request comes in, I have to verify if the client has the proper authorizati ...

What is the best way to display all mysql rows in Node.js using handlebars templating?

Here is the code snippet I used to share only the first row (jack) from MySQL: node: const express = require("express"); const app = express(); app.set("view engine","hbs") const mysql = require("mysql") const db = m ...

Encountered a gulp-csslint error while executing gulp within the MeanJS wrapper

After setting up meanJS, I encountered an error while trying to run gulp/grunt. Node v6.2.2 npm v3.9.5 MeanJS v0.4.2 ../node_modules/gulp-csslint/node_modules/rcloader/index.js:36 if (err) throw err;      &nbs ...

Tips for correctly mentioning a user while using message.channel.send in discord.js

Looking for guidance on tagging a user properly using message.channel.send in discord.js? Here's the code I'm currently working with: function replaceAll(str, find, replacer) { return str.replace(new RegExp(find, 'g'), replacer) ...

Bootstrap 4 - Content positioned on the left side of the screen next to an image ... on mobile devices, the text appears below

How can I ensure in Bootstrap 4 (and possibly other versions) that the text appears to the left of the image on the screen, and that the image is displayed above the text on smartphones? Here is my source code: <div class="container"> <div cla ...

Is it possible to include a hidden default option that provides a description for my `select` tag?

Can someone help me create a description for the select tag that won't show up in the drop-down options? I remember seeing this done somewhere, but I can't recall where. Any suggestions? This is what I am trying to achieve: <fieldset> ...