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

serverless-s3-assets

v1.0.2

Published

Uploads requested assets to S3 as part of Serverless deploy

Downloads

156

Readme

Serverless S3 assets

Sometimes you have some fixed assets that need to be uploaded to S3, such as images or css files. This plugin will do that, and delete the assets when you run serverless remove.

Build Status Coverage Status npm

How to use

To use this, you'll need to specify the files to copy to your bucket. You do this in serverless.yml:

plugins:
  - serverless-s3-assets

custom:
  s3Assets:
    test-html:
      bucket: ${self:custom.shared.s3Bucket}
      isPublic: false
      cacheTime: 300
      contentType: text/html
      templates:
        cacheTime: 20

The test-html is the relative folder name of the files to upload to the bucket. The possible options available are:

  • bucket: Only available to use on the root folder. This defines the name of the bucket to upload these files to.
  • acl: Set this to a specific, valid ACL setting.
  • isPublic: set this to true or false to override any ACL setting. True is the same as public-read and false is the same as private.
  • cacheControl: Any cache control settings.
  • cacheTime: This overrides any existing cache-control settings and sets a max-age for the file.
  • contentType: default type of content we're uploading, if not obvious. Plugin will try to derive the type from file extention first.
  • metadata: Any extra metadata to upload.

Any other options specified will be treated as sub-folder names, like templates above. This also shows you how to have sub-folders with different settings. By default, all files and folders within the specified root folder name will be uploaded with the same options as that root folder.

Commands

The code will trigger automatically during a serverless deploy and serverless remove.

You can also carry out S3 deployment or removal independent from stack deployments:

sls s3delpoy

sls s3remove

If you have defined multiple assets (folders) you can limit the action to a single one:

sls s3delpoy --asset test-html

Gotchas

Make sure you don't add any additional files to your bucket that you're specifying in s3Assets. If you do and then run serverless remove then those additional files will also be removed.

Permissions

You don't need any special permissions for your Lambda as the code is run by Serverless instead.