Linked Questions

Popular Questions

Gulp task not running properly

Asked by At

A little context: I am following this tutorial: and at time 23:20 we have created a gulpfile.js that will take a scss file and convert it to css. Since I needed to modify the code to Gulp 4, here is my code:

'use strict';

//Dependencies
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var changed = require('gulp-changed');



////////////////////
// - SCSS/CSS
////////////////////

var SCSS_SRC = '.src/Assets/Assets/*.scss';
var SCSS_DEST = './src/Assets/css';

//Compile SCSS
gulp.task('compile_scss', gulp.series(function(){
  gulp.src(SCSS_SRC)
  .pipe(sass().on('error', sass.logError))
  .pipe(minifyCSS())
  .pipe(rename({ suffix: '.min' }))
  .pipe(changed(SCSS_DEST))
  .pipe(gulp.dest(SCSS_DEST));
}));

//Detect changes in SCSS
gulp.task('watch_scss', gulp.series(function(){
  gulp.watch(SCSS_SRC, gulp.series(['compile_scss']))
}));


//Run tasks
gulp.task('default', gulp.series(['watch_scss']));

What were you expecting to happen? I am expecting it to create a css file in the appropriate path.

What actually happened? No css file created

What version of gulp are you using? version 4 What versions of npm and node are you using? npm: 6.4.1 Node: v10.15.1

When I run the gulp command in my project, I get the following:

[21:35:41] Using gulpfile ~\Desktop\reactTutorial\personal-website\src\gulpfile.js
[21:35:41] Starting 'default'...
[21:35:41] Starting 'watch_scss'...
[21:35:41] Starting '<anonymous>'...```

I assume its running right but it doesnt seem like its actually able to access the 'compile_scss'

Related Questions