G
G
givrzn2017-03-15 14:48:00
css
givrzn, 2017-03-15 14:48:00

How to write a task for Gulp so that the file is collected in one?

I am compiling Gulp for a project.
Zaparka was created on the simplest place.

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

A simple task for gulp-sass.
And here's what I need.
The files must be collected into one file.
And then another task to minify.
At the same time, there should not be any garbage.
That is, no separate css files.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Zhivagin, 2017-03-15
@Krasnodar_etc

You make some app.sass file, where

@import 'first.sass';
@import '../second.sass';
...

In short, you include everything you need in it. Here is the file and convert gulp to css

I
iBird Rose, 2017-03-15
@iiiBird

var concat 		= require('gulp-concat');
var minifyCSS 		= require('gulp-minify-css');

var SCSSfiles = ['assets/sass/**/*.scss', '!assets/sass/reset.scss', '!assets/sass/all.scss'];
var resetCSS = ['assets/sass/reset.scss'];
var allCSS = ['assets/sass/all.scss'];
var resetFirst = resetCSS.concat(allCSS);
var concatFiles = resetFirst.concat(SCSSfiles);
gulp.task('sass', function() {
  return gulp.src(concatFiles)
  .pipe(concat('styles.min.scss'))
        .pipe(sass().on('error', sass.logError))
  .pipe(minifyCSS())
  .pipe(gulp.dest('assets/css'));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question