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

webpack-s3-pusher-adapted

v2.0.7

Published

A webpack plugin that pushes your packed assets to your S3 bucket, no more, no less.

Downloads

12

Readme

Source & Credits

All credits to Oliver Green
Original work olsgreen/webpack-s3-pusher

Changes

This fork allows passing the endpoint as option to facilitate connecting to AWS compatible providers like DigitalOcean.
In addition, you can now pass the desired ACL to be applied to the uploaded files. By default, some providers set the file visibility to private which contradicts with the need of pushing content to CDN for high availability. Now the user can set the option acl to public-read to force public visibility.

webpack-s3-pusher

A webpack plugin that pushes your packed assets to your S3 bucket, no more, no less.

For webpack < 4 support use version 1.x

Installation

npm install webpack-s3-pusher-adapted --save-dev

Configuration

new S3PusherPlugin({
	 // Target bucket
    bucket: 'BUCKET',
    
    // Set the credentials.
    key: 'KEY',
    secret: 'SECRET',
    region: 'us-west-2',
    
    // Publish to 'assets' folder
    prefix: 'assets',        
    
    // Include css & js files   
    include: '/.*\.(css|js)/'
    
    // Exclude minified JS files
    exclude: '/.*.min.js/'      
    
    // Remove files from the bucket before upload.
    remove: [                   
    	'path/to/file1.js',
    	'path/to/file2.js',
    ]
})

You can also use a credentials file from AWS rather than passing the

Push assets to S3 from Laravel Mix

.env

APP_ASSETS_AWS_KEY=your_key
APP_ASSETS_AWS_SECRET=your_secret
APP_ASSETS_AWS_REGION=your_region
APP_ASSETS_AWS_BUCKET=your_bucket
APP_ASSETS_AWS_ENDPOINT=your_endpoint
APP_ASSETS_AWS_ACL=your_acl
APP_CDN_URL=http://my-bucket.s3-website.eu-west-2.amazonaws.com

webpack.mix.js:

const { mix } = require('laravel-mix');
const S3PusherPlugin = require('webpack-s3-pusher')

let config = {
    plugins: [],
};

if (process.env.npm_config_env === 'staging' || process.env.NODE_ENV === 'production') {
    config.output.publicPath = process.env.APP_CDN_URL + '/';
    config.plugins.push(
        new S3PusherPlugin({
            key: process.env.APP_ASSETS_AWS_KEY,
            secret: process.env.APP_ASSETS_AWS_SECRET,
            region: process.env.APP_ASSETS_AWS_REGION,
            bucket: process.env.APP_ASSETS_AWS_BUCKET,
        })
    )
}

mix.webpackConfig(config);

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .version();

Then you will be able to push to S3 using:

npm run production
// or
npm run dev --env=staging

Contributing

Pull requests welcome 🙂