jussi-kalliokoski / gulp-awspublish-router

A router for defining file-specific rules with gulp-awspublish

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exiting after the first file with Gzip

geelen opened this issue · comments

Adding gzip: true causes the stream to exit after the first matching file:

    return gulp.src("release/**")
      .pipe($.awspublishRouter({
        cache: {
          cacheTime: 86400 // Cache for 1 day by default
        },
        routes: {
          // Drop .html from HTML files and GZIP
          "^(.+)\\.html$": {
            key: "$1",
            gzip: true
          },
          // Passthrough everything else
          "^.*$": "$&"
        }
      }))
      .pipe(publisher.publish())
      .pipe(publisher.cache())
      .pipe($.awspublish.reporter());

I get the output:

[17:18:47] [cache]  about-us.html

If I change gzip to false, I get:

[17:19:32] [cache]  about-us
[17:19:32] [cache]  business
[17:19:32] [cache]  getting-started
[17:19:32] [cache]  index
[17:19:32] [cache]  legal
[17:19:32] [cache]  personal
etc...

Couldn't figure out how to fix it otherwise I'd have sent a PR. Sorry!

I have the same problem.

When no gzip:

var piped = gulp.src([ base + '/**/*' ], { base: path.resolve(base) })
        .pipe(awsPublishRouter({
            cache: {
                cacheTime: 1000 * 60 * 60 * 24 * 365 // 1 year
            }
          , routes: {
                // Text assets get gzipped
                '^.+\.(?:json|js|css|topojson|geojson|svg)$': {
                    gzip: false
                  , key: uploadPath + '$&'
                }
                // HTML gets shorter cache time
              , '^.+\.html$': {
                    gzip: false
                  , key: uploadPath + '$&'
                  , cacheTime: 1000 * 60 * 5 // 5 minutes
                }
                // Passthrough for everything else
              , '^.+$': '$&'
            }
        }))
        .pipe(require('gulp-debug')())
        .pipe(publisher.publish())
        .pipe(awsPublish.reporter())
        .pipe(run(cb))

I get the following output:

[16:47:16] [update] stage/explorer/app.23dffaa7.js
[16:47:19] [create] stage/explorer/app.js
[16:47:23] [create] stage/explorer/d3-3.4.11.8f16cc41.js
[16:47:26] [create] stage/explorer/d3-3.4.11.js
[16:47:27] [create] stage/explorer/index.16fba4cc.css
[16:47:27] [create] stage/explorer/index.css
[16:47:27] [create] stage/explorer/index.html
[16:47:27] [create] stage/explorer/jquery-1.11.1.74be1697.js
[16:47:28] [create] stage/explorer/jquery-1.11.1.js
[16:47:31] [create] stage/explorer/jquery-2.1.1.da04679d.js
[16:47:34] [create] stage/explorer/jquery-2.1.1.js
[16:47:35] [create] stage/explorer/jquery.xdomainrequest-1.0.3.min.00b63fbb.js
[16:47:35] [create] stage/explorer/jquery.xdomainrequest-1.0.3.min.js
[16:47:35] [create] stage/explorer/modernizr.ca62206e.js
[16:47:35] [create] stage/explorer/modernizr.js
[16:47:36] [create] stage/explorer/postoffice.d7270297.js
[16:47:36] [create] stage/explorer/postoffice.js
[16:47:36] [create] /img/select2-spinner.a0b1b303.gif
[16:47:36] [create] /img/select2-spinner.gif
[16:47:37] [create] /img/select2.cb234a71.png
[16:47:37] [create] /img/select2.png
[16:47:37] [create] /img/select2x2.066c9beb.png
[16:47:37] [create] /img/select2x2.png

And with the same config but gzip: true instead of gzip: false I get:

[update] stage/explorer/app.23dffaa7.js

I've put a gulp-debug after the router and when gzipped it only logs one file coming through. When not gzipped it logs all.

Interesting thing with the gulp-debug output, when not gzip and all get passed through:

[16:47:14] gulp-debug: end event fired (2014-09-16 06:47:14 UTC)

Yet when gzip is true, the end event notification never appears.

Sorry for the wait on this one, taking a look now.

I just released v0.0.1 with the fix. Could you guys verify that the problem is solved for you? Thanks for reporting, providing info and being patient!

The fix works for me, thanks!