D
D
Dima Glazunov2019-12-01 16:48:55
Sass
Dima Glazunov, 2019-12-01 16:48:55

What is wrong with the algorithm in gulpfile js?

I recently started learning Gulp 4 and I can't figure out how to compile sass/scss to css. the css file is simply not created. Nowhere. Tell me, what's the problem?

gulp.task('sass', function(done) {
  return gulp.src('app/sass/**/*.sass')
  .pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
  .pipe(rename({suffix: '.min', prefix : ''}))
  .pipe(autoprefixer(['last 15 versions']))
  .pipe(cleanCSS()) // Опционально, закомментировать при отладке
  .pipe(gulp.dest('app/css'))
  .pipe(browserSync.reload({stream: true}));
  done()
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roma Zvarich, 2019-12-01
@NoLoL241

Since there is very little incoming data, you have to guess the first thing that can be assumed that you are looking for files with the extension in the line , and you are writing the code, possibly in scss with the same extension . Since there are no source files with the required extension, nothing is created. If not, please clarify if any errors appear in the console. Better yet, put the archive with the project somewhere on https://fex.net/ so that you can study the project normally.

T
TCloud, 2019-12-01
@OTCloud

It’s not entirely clear what errors gulp gives you, you’re definitely calling it in the wrong place done(), but below is the working version.

var gulp     	 	= require('gulp'),
    sass     	 	= require('gulp-sass'),
    concat   	 	= require('gulp-concat'),
    autoprefixer 	= require('gulp-autoprefixer'),
    browserSync  	= require('browser-sync');

gulp.task('SassToCss', function () {
  return gulp.src('app/sass/main.sass')
    .pipe(sass())
    .pipe(autoprefixer([ 'last 15 versions', '> 1%', 'ie 8', 'ie 7' ], { cascade: true }))
    .pipe(concat('main.css'))
    .pipe(gulp.dest('app/css'))
    .pipe(browserSync.reload({stream: true}));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question