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

npm-assets

v0.1.2

Published

Bundle static files with NPM packages

Downloads

986

Readme

npm-assets

license:mit tag:? build:? coverage:? npm:? dependencies:? devDependencies:?

Use static files from NPM packages.

This is a tool for copying static files (fonts, CSS, images, etc.) declared and packaged in NPM modules into a folder. To define static files in a package, add a assets field to the package.json containing an array of files to include. These files will be copied (preserving the same directory structure) when this tools is ran. It will recursively search for modules in the node_modules folder.`

How ?

Lets say you have a dependency - mysite-css - which has a couple of CSS files and an image that you'd like to use in your project. mysite-css has a package.json that looks like this:

{
  "name": "mysite-css",
  "assets": [
    "bootstrap.css",
    "index.css",
    "logo.png"
  ]
}

If you run npm-assets public/ - npm assets will look inside node_modules/mysite-css/package.json and see the 3 listed assets. After npm-assets has run, you should see public/ contains those 3 assets!

$ ls public
bootsrap.css  index.css  logo.png

JS Example

var assets = require('npm-assets');
assets(
    process.cwd(), // root directory
    'assets',      // destination directory
    done);         // callback

npm-assets(1)

Also included is the npm-assets executable. Simply run npm-assets <dest> to search for all assets from modules in the current folder and copy them to the dest folder.

# Copy all assets to the `assets` folder
npm-assets assets

PFAQ (Potentially Frequently Asked Questions)

What if I have two dependencies that both have a file with the same name?

If you have two dependencies, and both have an identically named file (for example both have a logo.png asset). npm-assets will copy only the first of those, when listed alphabetically. So if a-module/logo.png and b-module/logo.png are both listed as assets, a-module/logo.png will be copied over, and b-module/logo.png will be ignored.