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

@dev-spendesk/plugin-rewire-assets

v1.0.0-rc.10

Published

Module to handle files outside _assets

Downloads

2

Readme

@fab/plugin-rewire-assets

A plugin for moving any files not handled by another plugin to the _assets folder. Usually the last in the sequence.

Rationale

Since a FAB can only have two components, a server.js entry-point and an _assets directory (see FAB Structure for more info), any files not handled by other plugins need to moved into place.

There are a few common use-cases:

  • Small files with predictable public URLs, e.g. favicon.ico or robots.txt
  • Larger assets that are not properly handled by a build tool e.g. /public/logo.png
  • Compiled assets that don't follow the /_assets naming pattern

This module acts as a catch-all, with different behaviour based on the type of file being processed, or via config.

Usage

{
  plugins: {
    // ... all existing plugins should go here, rewire-assets should be last
    '@fab/plugin-rewire-assets': {
      // Can be left blank. See below for config options
    },
  },
}

Configuration

By default, this module has the following options:

{
  'inline-threshold': 8192, // size, in bytes, before a file is inlined
  'treat-as-immutable': '/\\.[0-9A-F]{8,}\\./i', // path to match for immutable assets
}

Note: treat-as-immutable takes a string that represents a RegExp using regex-parser syntax. TL;DR, it's exactly what a literal JS RegExp would look like, with double-escaped backslashes.

inline-threshold

For small files, it's more efficient for the FAB to serve them directly than to upload them to an asset host and fetch them from there. The default value of 8192 bytes is usually big enough for handle favicons, robots.txt & asset manifests, without bloating the server.js too substantially.

treat-as-immutable

This RegExp matches files that the FAB should consider as immutable, despite the fact that they're not in the _assets directory. In general, FABs assume all files in _assets are immutable and all files outside are not, but this option is introduced in order to handle a fairly common use-case: when your files are immutable but aren't in _assets yet.

To understand how this works, consider two files, one called /public/styles.css and one called /public/main.a1b2c3d4.js. For the CSS file, since the public URL has no content hash (also called a fingerprint), the FAB has no way of knowing how long it is safe to cache that file for.

For the JS file, since Webpack or similar has injected an 8-hex-digit content hash into the filename, any revisions to the content will result in a new URL, so this file can be cached indefinitely, just like files already in _assets.

The default is for any files that have at least 8 hex-only digits between two . chars, matching the common convention of /path/to/filename.[hash].type

How it works

Each file that isn't inlined is hashed, then moved into the _assets directory. When a request for the original path comes in, the FAB fetches the moved file and serves it, altering the cache headers as required.