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

node-s3-cdn

v0.4.1

Published

Node.js module for versioning and uploading your assets to S3.

Readme

node-s3-cdn

A simple Node.js library for versioning and uploading your assets to S3, then pointing to those assets in your views, stylesheets, and scripts.

For the TL;DR version see /test/gulpfile.js

Express, Gulp, Handlebars, and Sass are used throughout, but helpers and examples for other libs are more than welcome.

##Configuration

Instantiate the cdn with your s3 credentials and config options.

Then set your Sass up to compile in Gulp (or whatever):

...or set your Handlebars up to compile in Express (or whatever):

##Using template helpers

If you write Sass like this:

It will come out like this when NODE_ENV === 'production':

And like this otherwise:

If you write Handlebars like this:

It will come out like this when NODE_ENV === 'production':

And like this otherwise:

##Uploading assets to S3

To generate a new version hash and upload the contents of ./asset_folder/* to your_s3_bucket/version_hash/*:

Remember when you set hashFile: __dirname + '/your_asset_version_hash_will_be_stored_here.json' above? That file will be updated whenever you run cdn.upload to match the new version hash, which will be the name of the tag on S3 that your assets are now stored under. This file is how your template helpers will know how to write out full cdn urls.

From there you can configure Cloudfront to point to your S3 bucket and serve assets from https://your.cdn.domain.com.

##Versioning assets

To create a new version of your assets, run:

You can run cdn.upload as many times as you want on the same version, only changed files will be overwritten.

##Cleaning up previous versions

IMPORTANT CAVEAT: cdn.clean will delete every other tag in your s3 bucket except the current asset version.

##Let's go over that again because this is very important

WHEN YOU RUN CDN.CLEAN IT WILL DELETE EVERY OTHER TAG IN YOUR S3 BUCKET EXCEPT THE CURRENT ASSET VERSION.

MAKE A SEPARATE S3 BUCKET SO YOU CAN VERSION YOUR CDN ASSETS. SERIOUSLY.

##Contributing This is a very early version, feel free to file issues and pull requests for bug reports / suggestions / tests / etc.