Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to get size report of already minified files #16

Open
JayBox325 opened this issue Jan 28, 2019 · 1 comment
Open

Trying to get size report of already minified files #16

JayBox325 opened this issue Jan 28, 2019 · 1 comment

Comments

@JayBox325
Copy link

I have a sizereport task as follows:

gulp.task('sizereport', () => {
    return gulp.src('build/assets/**/*.*)
        .pipe(production(sizereport({
            gzip: true,
            minifier: function (contents, filepath) {
                if (filepath.match(/\.min\./g)) {
                    return contents
                }
            }
        })))
})

As all of my assets (Js, Scss etc) are being minified conditionally based on the environment in each of their own tasks. I was hoping this snippet above would pick up on those and show the .min versions alongside the non-minified versions.

However, I appear to be getting the following error:

TypeError: Cannot read property 'length' of undefined
    at DestroyableTransform._transform (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/gulp-sizereport/index.js:100:43)
    at DestroyableTransform.Transform._read (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_transform.js:172:83)
    at doWrite (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at DestroyableTransform.Writable.write (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at DestroyableTransform.ondata (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at DestroyableTransform.emit (events.js:188:13)
    at DestroyableTransform.EventEmitter.emit (domain.js:459:23)
    at addChunk (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_readable.js:291:12)
    at readableAddChunk (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_readable.js:278:11)
    at DestroyableTransform.Readable.push (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_readable.js:245:10)
    at DestroyableTransform.Transform.push (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/readable-stream/lib/_stream_transform.js:148:32)
    at Pumpify.onReadable (/Users/jaycollett/Development/jaycollett/jaybox 2/node_modules/to-through/index.js:25:14)
    at Pumpify.emit (events.js:188:13)
    at Pumpify.EventEmitter.emit (domain.js:459:23)

When I change the source directory to just /build/assets/ I no longer get the error, but I also don't get the report.

Any help would be appreciated.

Thanks,
Jay

@jaysalvat
Copy link
Owner

Hello,

Try returning something in the the minifier function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants