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 🙏

© 2025 – Pkg Stats / Ryan Hefner

copy-assets

v1.0.3

Published

Copy assets with specific extensions, prefix, suffix

Downloads

217

Readme

copy-assets

Copy assets with specific extensions, prefix, suffix or thanks to a regex

Installation

npm i -g copy-assets

# or locally
npm i --save copy-assets

# then, you might do this
npm i --save-dev copy-assets

Why ?

To be honest, I was bored to use gulp to copy files from my projects sources to the build folder so as to run webpack

I decided to make a command specially for this and then keeping the architecture of the sources but only copying the files I want

Going from this :

|- dist - b - file1.js
\- src
    |- a - file1.png
    |- b - file1.ts
    \- c - file2.png

To that :

|- dist - a - file1.png
|   |---- b - file1.js
|   \---- c - file2.png
|
\- src
    |- a - file1.png
    |- b - file1.ts
    \- c - file2.png

In one command

Usage

API

Basically, running a copy goes like this:

const copy = require('copy-assets').default

copy({
    src: 'path_to_source',
    dist: 'path_to_destination',
    whitelist: [], // Array of filters,
    blacklist: [], // Array of filters,
    importWebpack: true,
    webpackConfig: 'webpack.dev.config.js',
    verbose: true
})

If any file match one of the whitelist filters AND none of the blacklist filers, then it will be copied from the source to the destination

The copy will look recursively for the files and then create the needed folders

Every field of the config is required, otherwise, it may crash.

Filter

A filter is an object with some optional fields: extension, prefix, suffix, regex, match

let filter = {
  extensions: '.js', // or just 'js',
  prefix: 'prefix_',
  suffix: '_suffix',
  regex: new RegExp('^_anotherOne?'),
  match: function(filename, filepath) {
    return true
  }
}

A file should match every fields of a filter to be copied, then you can target only js files with prefix, or suffix, or use a custom matching function

Cli

This is the purpose of that package, here is the usage:

Usage: copy-assets <source> <destination> [options]

  Options:

    --help - Show this

    --ext=.js - Allow files with a specific suffix

    --exts=".js,.css,.cscc" - Same as --ext but works will multiple extensions at once, joined with a ","

    --prefix=dist_ - Allow files with a specific prefix

    --suffix=_dist - Allow files with a specific suffix

    --allowRegex="^prefix_" - Allow files matching regex

    --banRegex="^prefix_" - Ban files matching regex

    --importWebpack=webpack.config.js, -w webpack.config.js - Import extensions from webpack rules

    --verbose, v - Print out some info

    Note: Using !, * or other special selectors will not work, maybe it would one day

The most important thing is that you can import extensions from webpack rules automatically

License

MIT