5

I am new to gulp sass so I am currently learning with this https://css-tricks.com/gulp-for-beginners/. The current topic I am working from the above link is #Preprocessing with Gulp

All the stuff is getting fine until I test my sass file after testing it ( to know that it is compiling the CSS ) I trigger that it is not compiling SCSS to CSS why is it so.

Thinks to know.

  1. I am currently not working on my localhost. I have made the project file on my desktop.

  2. I have created the CSS file manually for the first time to see that my SCSS compiles my Current CSS file

What I am doing wrong.

UPDATE :

Inside my Gulp file :

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

gulp.task( 'sass', function() {
    return gulp.src('app/scss/**/*.scss')
      .pipe(sass())
      .pipe(gulp.dest('app/css'));
})

My file structure:

|- app/
      |- css/
      |- fonts/
      |- images/ 
      |- index.html
      |- js/ 
      |- scss/
           |- style.scss
|- dist/
|- gulpfile.js
|- node_modules/
|- package.json

Note: The file Structure is same as in the CSS Trick.

19
  • 4
    show us your gulpfile and file structure Commented Oct 4, 2017 at 7:48
  • @magreenberg Let me update. Commented Oct 4, 2017 at 7:49
  • @magreenberg I have updated my answer with my file structure and grunt file code Commented Oct 4, 2017 at 7:54
  • Do you have any folders in scss? The glob app/scss/**/*.scss is only going to see files with a .scss extension inside a subfolder. Commented Oct 4, 2017 at 7:57
  • do you get any errors when you run the sass task? Commented Oct 4, 2017 at 7:57

3 Answers 3

1

Try adding ./ to your source path:

return gulp.src('./app/scss/**/*.scss')
...

This tells it to start from the current directory, relative to the gulpfile.

Edit - you'll also need the same thing for the destination path:

  .pipe(gulp.dest('./app/css'));
Sign up to request clarification or add additional context in comments.

Comments

1

Your gulpfile looks ok. Your folder structure is ok.

I would like to ask wether you installed gulp-sass in your machine.

If you have not install.

Install it npm install gulp-sass --save-dev.

You don't need actually to create css file to test wether it works or not. It's ok if you have created too.

Check and let us know. Thanks.

Comments

1

you need to remove the semicolon on this line

.pipe(gulp.dest('app/css'));

and add one o the end of the task, like this

gulp.task( 'sass', function() {
    return gulp.src('app/scss/**/*.scss')
      .pipe(sass())
      .pipe(gulp.dest('app/css'))
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.