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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dotcom-tool-kit/upload-assets-to-s3

v4.1.1

Published

Upload files to a configured AWS S3 bucket.

Downloads

1,414

Readme

@dotcom-tool-kit/upload-assets-to-s3

Upload files to a configured AWS S3 bucket.

Installation

Install @dotcom-tool-kit/upload-assets-to-s3 as a devDependency in your app:

npm install --save-dev @dotcom-tool-kit/upload-assets-to-s3

Add the plugin to your Tool Kit configuration:

plugins:
	- '@dotcom-tool-kit/upload-assets-to-s3'

Tasks

UploadAssetsToS3

Upload files to an AWS S3 bucket.

Task options

| Property | Description | Type | Default | | :---------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :--------------------------------------------------------------------------- | | accessKeyIdEnvVar | variable name of the project's aws access key id. If uploading to multiple buckets the same credentials will need to work for all | string | 'AWS_ACCESS_HASHED_ASSETS' | | secretAccessKeyEnvVar | variable name of the project's aws secret access key | string | 'AWS_SECRET_HASHED_ASSETS' | | directory | the folder in the project whose contents will be uploaded to S3 | string | 'public' | | reviewBucket | the development or test S3 bucket | Array<string> | ["ft-next-hashed-assets-preview"] | | prodBucket | production S3 bucket(s). The same files will be uploaded to each. Note: most Customer Products buckets that have a prod and prod-us version are already configured in AWS to replicate file changes from one to the other so you don't need to specify both here. Also, if multiple buckets are specified the same credentials will need to be valid for both for the upload to be successful. | Array<string> | ["ft-next-hashed-assets-prod"] | | region | the AWS region your buckets are stored in (let the Platforms team know if you need to upload to multiple buckets in multiple regions). | string | 'eu-west-1' | | destination | the destination folder for uploaded assets. Set to '' to upload assets to the top level of the bucket | string | 'hashed-assets/page-kit' | | extensions | file extensions to be uploaded to S3 | string | 'js,css,map,gz,br,png,jpg,jpeg,gif,webp,svg,ico,json' | | cacheControl | header that controls how long your files stay in a CloudFront cache before CloudFront forwards another request to your origin | string | 'public, max-age=31536000, stale-while-revalidate=60, stale-if-error=3600' |

All properties are optional.

Testing uploads using the review bucket

You can test uploads to S3 locally on your review bucket to check that you are happy with the configuration. To do this set your NODE_ENV to branch:

$ export NODE_ENV=branch

If the AWS key names for accessing the review bucket are different to the prod bucket then update those in the .toolkitrc.yml.

The UploadAssetsToS3 task can run on any hook so you can configure it to run on a local hook to test deployment from the command line. For example, it could be added to your build:local hook as follows:

plugins:
  - '@dotcom-tool-kit/webpack'
  - '@dotcom-tool-kit/upload-assets-to-s3'
hooks:
  'build:local':
    - WebpackDevelopment
    - UploadAssetsToS3

Then running npm run build will run the UploadAssetsToS3 task on your review bucket.

Tasks

| Name | Description | Preconfigured Hook| |-|-|-| | UploadAssetsTos3 | Uploads provided files to a given S3 bucket | release:remote |