Y
Y
Yaroslav Akulov2016-06-23 00:04:14
css
Yaroslav Akulov, 2016-06-23 00:04:14

Is it possible to create a task in gallp...?

Guys, help me through the gallp to create a task so that the sass file is compiled into the usual style.css and then immediately into the minified min.style.css (that is, it turns out you need 3 files: style.sass, style.css and min.style.css )? When changing the sass file, there were changes in the css and min.css, and when the css was changed, there were changes in the min.css (minify using the plugin in the clean CSS galle).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Kayun, 2016-06-23
@uRusure

Styles

const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const rename = require('gulp-rename');
const csso = require('gulp-csso');
const config = require('../config.js').styles;

gulp.task('styles', () => {
  return gulp.src(config.entry, {cwd: config.srcDir})
    .pipe(sourcemaps.init())
    .pipe(sass())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(config.distDir))
    .pipe(csso()))
    .pipe(rename({
      extname: 'min'
    }))
    .pipe(gulp.dest(config.distDir));
});
});

Tracking
const gulp = require('gulp');
const config = require('../config.js');

gulp.task('watch', () => {
  gulp.watch(`${config.path.styles}**/*.sass`, ['styles']);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question