sindresorhus / gulp-size

Display the size of your project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to add custom message

gonzalocasas opened this issue · comments

It is not uncommon to wish to see CSS size and scripts' size, so it would be great to be able to specify an additional/custom message to be displayed when rendering the calculated size.

Custom message for what purpose exactly?

To be able to distinguish between multiple calls of gulp-size.
See the following:
image

There are two lines generated by gulp-size, one is generated by the 'styles' stream, the other one is generated by the 'scripts' stream. As it is right now, it's impossible to tell which is which.

If a custom message doesn't fit, then giving it a name or something that would be in the output of gulp-size would also do.

This should really be fixed in gulp, but I've added a hacky solution in the interim. Mind trying out master?

Just tested on master and it doesn't really work, if you have multiple size() calls, it always show the same message. Take the following minimal gulpfile sample:

gulp.task('test-styles', function () {
    return gulp.src(paths.css)
        .pipe(size());
});
gulp.task('test-libs', function () {
    return gulp.src(paths.jslibs)
        .pipe(size());
});
gulp.task('test', ['test-libs', 'test-styles'], function () {
});

This causes the following output:

[gulp] Starting 'test-libs'...
[gulp] Starting 'test-styles'...
[gulp] gulp-size: 'test-styles' total 17.22 kB
[gulp] Finished 'test-libs' after 17 ms
[gulp] gulp-size: 'test-styles' total 10.16 kB
[gulp] Finished 'test-styles' after 13 ms
[gulp] Starting 'test'...
[gulp] Finished 'test' after 7.19 μs

Notice the task name is the same in both cases.

In any case, I'd rather wait for/help develop a full proper solution instead of rushing a hacky one.

Oh well. I added an option to add a title instead, until it can be fixed in gulp itself ;)

Thanks!