How to use the gulp-awspublish.gzip function in gulp-awspublish

To help you get started, we’ve selected a few gulp-awspublish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / apm-agent-js-core / gulpfile.js View on Github external
// Set headers
  var headers = {
    'Cache-Control': 'max-age=1800, public'
  }

  var version = require('./package').version
  var majorVersion = version.match(/^(\d).(\d).(\d)/)[1]

  var versionPath = './dist/cdn/**'

  console.warn('Uploading All files in:', versionPath)

  return gulp.src([versionPath])
    // Gzip
    .pipe(awspublish.gzip())
    // Publish files with headers
    .pipe(publisher.publish(headers))
    // Create a cache file to speed up consecutive uploads
    .pipe(publisher.cache())
    // Print upload updates to console
    .pipe(awspublish.reporter())
})
github michaelBenin / react-ssr-spa / gulpfile.babel.js / tasks / gulp_upload_static_files.js View on Github external
const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  return gulp
    .src([
      `./dist/static/js/${manifestJSON['vendor.js']}`,
      `./dist/static/js/${manifestJSON['vendor.js.map']}`
    ])
    .pipe(
      rename(function renamePlugin(path) {
        path.dirname = `/${vendor}/${path.dirname}`; // eslint-disable-line no-param-reassign
        return path;
      })
    )
    .pipe(awspublish.gzip())
    .pipe(publisher.publish(headers))
    .pipe(awspublish.reporter());
});
github ffwdme / ffwdme.js / gulp / tasks / deploy.js View on Github external
gulp.task('deploy', ['build'], function() {
  var secrets = require('../../secrets.json');
  var publisher = awspublish.create({
    key:    secrets.aws.key,
    secret: secrets.aws.secret,
    bucket: secrets.aws.bucket
  });

  // weak caching, for debugging
  var headers = {
    'Cache-Control': 'max-age=120, no-transform, public'
  };

  return gulp.src('./build/**')
     // gzip, Set Content-Encoding headers
    .pipe(awspublish.gzip())
    // publisher will add Content-Length, Content-Type and headers specified above
    // If not specified it will set x-amz-acl to public-read by default
    .pipe(publisher.publish(headers))
    .on('error', handleErrors)
    // Delete old files
    .pipe(publisher.sync())
    // create a cache file to speed up consecutive uploads
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());
});
github productboard / webpack-deploy / tasks / deploy-s3.js View on Github external
const publisher = aws.create(config.credentials);

  // define custom headers
  const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public',
  };
  return (
    gulp
      .src(config.assetsPath)
      .pipe(
        rename(function(filepath) {
          filepath.dirname = path.join(config.dirname, filepath.dirname);
        }),
      )
      // gzip, Set Content-Encoding headers and add .gz extension
      .pipe(gulpIf(file => !file.path.match(/\.(mp4|ogg|webm|avi|mov|mkv)$/), aws.gzip()))
      // publisher will add Content-Length, Content-Type and headers specified above
      // If not specified it will set x-amz-acl to public-read by default
      .pipe(publisher.publish(headers))
      // create a cache file to speed up consecutive uploads
      .pipe(publisher.cache())
      // print upload updates to console
      .pipe(aws.reporter())
  );
}
github ladjs / lad / template / gulpfile.js View on Github external
function publish() {
  // create a new publisher
  const publisher = awspublish.create(
    _.merge(config.aws, {
      params: {
        Bucket: env.AWS_S3_BUCKET
      }
    })
  );
  return (
    src([`${config.buildBase}/**/*`, `!${config.manifest}`])
      // gzip, Set Content-Encoding headers and add .gz extension
      .pipe(awspublish.gzip())
      // publisher will add Content-Length, Content-Type
      // and headers specified below
      // If not specified it will set x-amz-acl to public-read by default
      .pipe(
        publisher.publish({
          'Cache-Control': `public, max-age=${ms('1yr')}`
        })
      )
      // create a cache file to speed up consecutive uploads
      .pipe(publisher.cache())
      // print upload updates to console
      .pipe(awspublish.reporter())
      .pipe(awscloudfront(env.AWS_CLOUDFRONT_DISTRIBUTION_ID))
  );
}
github jussi-kalliokoski / gulp-awspublish-router / index.js View on Github external
var route = _.find(routes, function (route) {
            return route.routeMatcher.test(file.relative);
        });

        file.s3.path = file.s3.path.replace(route.routeMatcher, route.key);
        applyCacheHeaders(file, route);
        _.extend(file.s3.headers, route.headers);

        if ( route.gzip ) {
            if ( route.gzip === true ) {
                route.gzip = {};
            }

            passThroughStream({
                target: self,
                modifier: awspublish.gzip(route.gzip),
                callback: callback,
                file: file
            });
        } else {
            self.push(file);
            callback();
        }
    });
};
github alice-si / monorepo / packages / donations-app / gulpfile.js View on Github external
function publishFrontend(awsConfName) {
  let awsConf = getAwsConf(awsConfName);
  let publisher = awspublish.create(awsConf.keys);
  return gulp.src(paths.getDistPath() + "/**/*")
    .pipe(awspublish.gzip({ ext: "" }))
    .pipe(publisher.publish(awsConf.headers))
    .pipe(cloudfront(awsConf.cf))
    .pipe(publisher.sync())
    .pipe(awspublish.reporter());
}
github keen / keen-js / gulpfile.js View on Github external
var jsHeaders = Object.assign({}, headers, {
    'Content-Type': 'application/javascript;charset=UTF-8'
  });

  var cssHeaders = Object.assign({}, headers, {
    'Content-Type': 'text/css'
  });

  gulp.src([
      './dist/keen.bundle.js',
      './dist/keen.bundle.min.js'
    ])
    .pipe(rename(function(path) {
      path.dirname += '/' + pkg['version'];
    }))
    .pipe(aws.gzip())
    .pipe(publisher.publish(jsHeaders, { force: true }))
    .pipe(publisher.cache())
    .pipe(aws.reporter());

  return gulp.src([
      './dist/keen.css',
      './dist/keen.min.css'
    ])
    .pipe(rename(function(path) {
      path.dirname += '/' + pkg['version'];
    }))
    .pipe(aws.gzip())
    .pipe(publisher.publish(cssHeaders, { force: true }))
    .pipe(publisher.cache())
    .pipe(aws.reporter());
github Wolox / frontend-bootstrap / gulp / tasks / s3.js View on Github external
gulp.task('s3push', () => {
  const awsConf = localConfig.getAwsConf(env);
  const publisher = awspublish.create(awsConf.keys);

  const unrevisionedHeaders = {
    ...awsConf.headers,
    'Cache-Control': 'max-age=0;smax-age=0;must-revalidate;'
  };

  const versioned = gulp.src(['./build/**/*', '!./build/index.html'])
    .pipe(awspublish.gzip({ ext: '' }))
    .pipe(parallelize(publisher.publish(awsConf.headers), 100));

  const unversioned = gulp.src('./build/index.html')
    .pipe(awspublish.gzip({ ext: '' }))
    .pipe(parallelize(publisher.publish(unrevisionedHeaders), 100));

  return merge(versioned, unversioned)
    .pipe(publisher.sync())
    .pipe(awspublish.reporter())
    .pipe(gulpif(!!awsConf.keys.distribution, invalidate(awsConf.keys)));
});

gulp-awspublish

gulp plugin to publish files to amazon s3

MIT
Latest version published 10 months ago

Package Health Score

67 / 100
Full package analysis