npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-cloudfront

v1.0.0

Published

Updates the Default Root Object of an AWS CloudFront distribution

Downloads

2,162

Readme

gulp-cloudfront Tests

Updates the Default Root Object of an AWS CloudFront distribution

Purpose

CloudFront lets you cache static assets for long periods, which is great for immutable build output and less great for index.html when you deploy a new version of a site.

One way to avoid broad cache invalidations is to publish revisioned assets, upload them to S3, and then point CloudFront's default root object at the latest revisioned HTML entrypoint. gulp-cloudfront handles that last step by finding the revisioned index file in your Gulp stream and updating the distribution.

This pairs well with gulp-rev-all and an S3 publishing step such as gulp-awspublish.

Install

npm install --save-dev gulp-cloudfront

gulp-cloudfront currently supports Node.js 18.18 or newer. The published package includes TypeScript declaration files.

Example

import gulp from "gulp";
import RevAll from "gulp-rev-all";
import awspublish from "gulp-awspublish";
import cloudfront from "gulp-cloudfront";

const aws = {
  distributionId: process.env.CLOUDFRONT_DISTRIBUTION_ID,
  region: "us-east-1",
};

export function deploy() {
  const publisher = awspublish.create({
    region: process.env.AWS_REGION || "us-east-1",
  });
  const headers = {
    "Cache-Control": "max-age=315360000, no-transform, public",
  };

  return gulp
    .src("dist/**", { base: "dist" })
    .pipe(RevAll.revision())
    .pipe(awspublish.gzip())
    .pipe(publisher.publish(headers))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter())
    .pipe(cloudfront(aws));
}

Options

distributionId

Type: string

Required. The CloudFront distribution to update.

patternIndex

Type: RegExp Default: /^\/index\.[a-f0-9]{8}\.html(?:\.gz)?$/i

Overrides the pattern used to identify the HTML file that should become the default root object.

const aws = {
  distributionId: process.env.CLOUDFRONT_DISTRIBUTION_ID,
  patternIndex: /^\/root\-[a-f0-9]{4}\.html(?:\.gz)?$/i,
};

region

Type: string Default: "us-east-1"

AWS region used to configure the SDK client. CloudFront is a global service, but the AWS SDK still requires a region for client resolution.

Credentials

If you do not pass explicit credentials, the AWS SDK v3 default credential chain is used.

You can also pass:

  • accessKeyId
  • secretAccessKey
  • key
  • secret
  • sessionToken
  • credentials

pushstate

Type: boolean | number[] Default: false

Rewrites matching CloudFront custom error responses to the newly published root object, which is useful for HTML5 pushstate routing.

Pass true to update both 403 and 404, or pass a list such as [404] to target specific status codes.

Notes

  • The plugin trims a trailing .gz suffix before updating DefaultRootObject.
  • Update failures are logged and the Vinyl stream continues, matching the historical plugin behavior.

License

MIT © Joshua Bellamy