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 🙏

© 2026 – Pkg Stats / Ryan Hefner

babel-plugin-asset-loader

v0.1.3

Published

Help to load your asset using babel

Downloads

9

Readme

babel-plugin-asset-loader

Installation

npm install babel-plugin-asset-loader --save
yarn add babel-plugin-asset-loader

Then put following "asset-loader" as plugin in .babelrc:

{
  "plugins": ["asset-loader"]
}

This is equivalent to following default configuration:

{
  "plugins": [
    [
      "asset-loader",
      {
        "name": "[hash].[ext]",
        "extensions": ["png", "jpg", "jpeg", "gif", "svg"],
        "outputPath": "/public",
        "context": "",
        "limit": 0
      }
    ]
  ]
}

Feature

This will import your asset into your package using babel and feel free to use your asset.

How it works

More or less as follows:

  1. Processes only import and require that reference files ending with one of "extensions"
  2. Calculates actual $name of resource by substituting placeholders in "name"
  3. Copies resource into $ROOT/$outputPath/$name where $ROOT is .babelrc location.
  4. Replaces import and require in code with "$publicPath/$name" string

Options

outputPath

Tells where to put static files. By default it's "/public".

This path is relative to the root of project. Setting value null prevents the plugin to copy the file.

name

The default is [hash].[ext] where:

|Name|Type|Default|Description| |:--:|:--:|:-----:|:----------| |[ext]|{String}|file.extname|The extension of the resource| |[name]|{String}|file.basename|The basename of the resource| |[path]|{String}|file.dirname|The path of the resource relative to the context| |[hash]|{String}|md5|The hash of the content, see below for more info|

The full format [hash] is: [<hashType>:hash:<digestType>:<length>], where:

|Name|Type|Default|Description| |:--:|:--:|:-----:|:----------| |hashType|{String}|md5|sha1, md5, sha256, sha512| |digestType|{String}|base64|hex, base26, base32, base36, base49, base52, base58, base62, base64| |length|{Number}|128|The length in chars|

For example: [md5:hash:base58:8] or [hash:base36].

extensions

List of extension asset-loader should look for in imports. All other imports are ignored.

context

Path to directory relative to .babelrc where application source resides. By default "", but can be e.g. "/src".

limit

Value in byte to determine if the content is base64 inlined. In that case, the file is not copy to outputPath. It replicates url-loader webpack loader behaviour.

Default is 0 which means nothing is inlined.

License

MIT