A
A
Alexey Yarkov2016-04-18 19:45:19
gulp.js
Alexey Yarkov, 2016-04-18 19:45:19

How to make gulp-filesize show the size correctly?

c418c22f43844b629947a8c809c6a34d.png
I included gulp-filesize and use it like this:

gulp.task('minify_css', ['compile_less'], function () {
  gulp.src([
        [options.output.cssdir, options.css_mask].join('/')
    ])
    .pipe(autoprefixer({
      cascad: true,
      browsers: ['last 3 versions']
    }))
    .on('error', console.log)
    .pipe(concat(options.output.cssMainFile))
    .on('error', console.log)
    .pipe(gulp.dest(options.output.cssdir))
    .on('error', console.log)
    .pipe(filesize())  // выводим размер
    .on('error', console.log)
    .pipe(csso())  // сжимаем
    .on('error', console.log)
    .pipe(filesize())  // выводим размер еще раз
    .on('error', console.log)
    .pipe(gulp.dest(options.output.cssdir));
});

But the size is not the same clearly. For example, a compressed file with scripts weighs 27, 35 Kb, and there is some crap on the screen.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Karimov, 2017-09-03
@trixden

Just put gulp-size
PS Despite its documentation, it is better to embed it at the end of the task.

gulp.task('default', () =>
    gulp.src('fixture.js')
        .pipe(gulp.dest('dist'))
        .pipe(size())
);

Otherwise, when you embed it before gulp.dest, it creates a null js file built by babelify/browserify

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question