izaakschroeder / vinyl-s3

Use S3 as a source or destination of vinyl files.
20 stars 16 forks source link

consider making options "gulp-data" compatible #21

Closed jamestalmage closed 9 years ago

jamestalmage commented 9 years ago

See https://www.npmjs.com/package/gulp-data .

var data = require('gulp-data');
var s3 = require('vinyl-s3');
var gzip = require('gulp-gzip');

gulp.src('*.js')
  .pipe(gzip())
  .pipe(data({contentEncoding: 'gzip'})
  .pipe(s3.dest('s3:/mybucket'))
izaakschroeder commented 9 years ago

Is there a reason you want to use input from gulp-data instead of

.pipe(s3.dest('s3://mybucket?ContentEncoding=gzip'))
izaakschroeder commented 9 years ago

As a secondary note, ContentEncoding should be automatically detected for you as long as your files have two extensions. e.g. .tar.gz, .html.gz, .css.gz, etc. See https://github.com/izaakschroeder/vinyl-s3/pull/5

jamestalmage commented 9 years ago

I am using it for an s3 hosted static website, and I would prefer the file names be index.html instead of index.html.gz (we are not supporting pre-gzip browsers since those went extinct almost 14 years ago).

I had oversimplified my example a bit.

var data = require('gulp-data');
var s3 = require('vinyl-s3');
var gzip = require('gulp-gzip');
var merge = require('merge-stream');

merge(
  gulp.src('*.js')
    .pipe(gzip())
    .pipe(data({contentEncoding: 'gzip'}),

  gulp.src('*.png') //don't gzip binary data
)
  .pipe(s3.dest('s3:/mybucket'))
izaakschroeder commented 9 years ago

Looking at the documentation here the default behaviour for gulp-gzip is to append the extension; seems like you're making life more complex than it needs to be :smile: Just adjust the index document in S3 and you'll need neither any fancy configuration for gulp-gzip nor any for vinyl-s3.

If you really want to do things the hard way then you can definitely use the query parameter approach.

var data = require('gulp-data');
var s3 = require('vinyl-s3');
var gzip = require('gulp-gzip');
var merge = require('merge-stream');

merge(
  gulp.src('*.js')
    .pipe(gzip({ append: false })) // turn off append to remove .gz extension
  gulp.src('*.png') //don't gzip binary data
)
  .pipe(s3.dest('s3://mybucket?ContentEncoding=gzip'))

I'm hesitant to use gulp-data for configuration both when I feel the existing approach works really well already AND that gulp-data seems to be used mainly for generating content (e.g. template engines, data stores, etc.) and not configuration. :smile:

jamestalmage commented 9 years ago

Fair enough. I'm currently using the setHeaders option to accomplish what I want. Your objections are well reasoned. Closing