sindresorhus / gulp-size

Display the size of your project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gziped and non gziped log

meefox opened this issue · comments

Could you add possibility to see gziped and non gziped size at the same time.
Thank you.

Why? I have yet to receive a good argument for it.

#12

This task is very useful for resources optimization work.
I have shared resources which is using by online(gzip) web-app and as offline phone app (non gzip).
So it would be useful to see progress for both.

I actually saw #12 and thought the same: why would anyone need both? Now I have an Electron app and web app built from the same resources and have to keep track of compressed / non-compressed file sizes. So yeah, I think @meefox has exactly the argument you're looking for @sindresorhus!

gzipped size is relevant for network performance while unzipped size is relevant for parse time performance. Both are relevant at the same time

Alright. Thanks for sharing some valid use-cases. PR welcome then :)

I made a workaround that works for my intended use, thought it may help someone:

function scss() {
    const s = size({ showTotal: false });
    const sgzipped = size({ showTotal: false, gzip: true });

    return gulp.src('./assets/sass/styles.scss')
        .pipe(sass())
        .pipe(concat('style.css'))
        .pipe(s).pipe(sgzipped)
        .pipe(gulp.dest('./'))
        .on('end', () => log(`Done building ${colors.magenta(`'style.css'`)}. (${s.prettySize} / ${sgzipped.prettySize} gzipped)`));
}

I using

gulp
    .src(/* sources */)
    .pipe(process.env.NODE_ENV !== 'production' ? sourcemaps.init() : noop())
    .pipe(sass().on('error', sass.logError))
    .pipe(postcss())
    .pipe(concat('style.min.css'))
    .pipe(
      process.env.NODE_ENV !== 'production' ? sourcemaps.write('.') : noop()
    )
    .pipe(size({gzip: process.env.NODE_ENV === 'production'}))
    .pipe(gulp.dest(/* output */))

and postcss config

const config = {
  plugins: [/* plugins */],
};

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(require('cssnano'));
}

module.exports = config;

Fixed by e5200f1.