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

assets-toolkit

v1.0.3

Published

Type-safe asset management CLI for React Native, Expo, React, Next.js and Vite. Automatically scans, validates and generates typed asset imports.

Readme

Assets Toolkit

Generate clean, typed, production-ready asset maps for React Native, Expo, React, Next.js, and Vite projects.

npm license typescript platforms

ssets Toolkit scans your project assets, validates them, detects duplicates and risky files, then generates a typed asset map you can import from your app code. It is built for teams that want asset access to feel boring in the best way: consistent names, stable imports, and fewer surprises during release.

It helps teams keep asset management predictable with:

  • Consistent asset names
  • Type-safe imports
  • Duplicate detection
  • Platform compatibility checks
  • Cleaner release builds
assets/                      generated-assets/
  logo.png        ─────▶       index.ts
  icons/search.svg             images-generate.ts
  fonts/Inter.ttf              svg-generate.ts
                               fonts-generate.ts

✨ Why Use It?

  • 🚀 Generate one typed Assets object from images, SVGs, fonts, audio, video, and Lottie files.
  • 🗂️ Preserve nested asset folder structures.
  • 🧹 Detect duplicate files before they increase app size.
  • 🛡️ Catch invalid filenames before Metro, Vite, Next.js, or CI builds fail.
  • 📊 Analyze asset usage and platform compatibility.
  • ♻️ Clean generated files and cache whenever required.

📦 Installation

Install it as a development dependency:

npm install --save-dev assets-toolkit

Or run it directly with npx:

npx assets-toolkit help

⚡ Quick Start

Put assets in one of the default folders:

assets/
  logo.png
  icons/
    search.svg
  fonts/
    Inter.ttf

Generate asset files:

npx assets-toolkit generate

Import generated assets:

import { Assets } from "./generated-assets";

const logo = Assets.images.logo;
const searchIcon = Assets.svg.images.search;
const font = Assets.fonts.fonts.Inter;

📁 Generated Location

Assets Toolkit automatically detects your project structure.

If your project contains a src folder:

src/
 ├── assets/
 └── generated-assets/

If your project does not contain a src folder:

assets/
generated-assets/

You can always override this using:

{
  "output": "custom/generated/path"
}

🌐 Platform Support

Assets Toolkit automatically detects your project platform.

| Platform | Images | SVG | Fonts | Audio | Video | Lottie | | ------------ | ------ | --- | ----- | ----- | ----- | ------ | | React Native | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Expo | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | React | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Next.js | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Vite | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |

Unsupported formats are reported during generation.


🧭 CLI Commands

| Command | Purpose | | ----------------- | --------------------------------- | | generate, -g | Generate typed asset files | | doctor | Validate assets and detect issues | | doctor --fix | Fix invalid filenames | | reports | Generate asset reports | | clean, -c | Remove generated files | | --version, -v | Show package version | | help, -h | Show CLI help |


🚀 Generate

Generate asset maps:

npx assets-toolkit generate

Alias:

npx assets-toolkit -g

Options:

npx assets-toolkit generate --outDir src/generated-assets
npx assets-toolkit generate --assetsDir assets
npx assets-toolkit generate --assetsDirs assets,src/shared/assets

The generator creates:

generated-assets/

 index.ts
 images-generate.ts
 svg-generate.ts
 fonts-generate.ts
 audio-generate.ts
 video-generate.ts
 lottie-generate.ts

Generated output:

export const Assets = {
  images,
  svg,
  fonts,
  audio,
  video,
  lottie,
} as const;

🩺 Doctor

Check your asset setup:

npx assets-toolkit doctor

Checks:

  • Missing asset folders
  • Invalid filenames
  • Duplicate assets
  • Unsupported formats
  • Large files

🛠 Doctor Fix

Preview fixes:

npx assets-toolkit doctor --fix

Skip the confirmation prompt when you want an automated cleanup:

npx assets-toolkit doctor --fix --yes

This command can:

  • Rename invalid filenames into safe asset names.
  • Avoid collisions with files that already exist.
  • Remove duplicate asset files after confirmation.

📊 Reports

Generate an asset report:

npx assets-toolkit reports

Includes:

  • Asset counts
  • Storage usage
  • Largest files
  • Extension breakdown
  • Generated output information

clean

♻️ Remove generated files and the Assets Toolkit cache.

npx assets-toolkit clean

Alias:

npx assets-toolkit -c

Use this when you want to regenerate from a clean state.

--version

🏷️ Print the installed package version.

npx assets-toolkit --version
npx assets-toolkit -v

help

💡 Show CLI help.

npx assets-toolkit help
npx assets-toolkit -h

⚙️ Configuration

On first run, Assets Toolkit creates:

assets-toolkit.config.json

Default:

{
  "assets": ["./src/assets", "./assets"],
  "output": "generated-assets",
  "target": "auto",
  "duplicates": "ignore"
}

Config Options

| Option | Type | Description | | ------------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | assets | string[] | Asset directories to scan. | | output | string | Directory where generated files are written. Must stay inside the project root. | | target | string | Valid target value: auto, react-native, expo, react, next, vite, or unknown. The CLI auto-detects the active platform from package dependencies. | | duplicates | string | Duplicate preference value: ignore, warn, or error. Duplicate files are surfaced by generate, doctor, and doctor --fix. |


🧩 Supported Assets

| Category | Extensions | | -------- | ------------------------------------------------------------------ | | Images | .png, .jpg, .jpeg, .gif, .webp, .avif, .heic, .ico | | SVG | .svg | | Fonts | .ttf, .otf, .woff, .woff2 | | Audio | .mp3, .wav, .aac, .m4a, .ogg, .flac, .opus | | Video | .mp4, .mov, .webm, .m4v | | Lottie | .lottie, valid Lottie .json |


🌍 Web Asset Handling

For React, Next.js, and Vite projects, generated assets use native ESM asset resolution:

export const images = {
  logo: new URL("../assets/images/logo.png", import.meta.url).href,
};

This allows bundlers like:

  • Webpack
  • Turbopack
  • Vite

to correctly resolve assets.


✅ Filename Rules

Recommended:

logo.png
logo-dark.svg
[email protected]
Inter.ttf

Avoid:

my logo.png
bad!name.svg
LOGO.PNG

Clean filenames produce predictable generated keys.


🧪 Recommended Workflow

Add scripts:

{
  "scripts": {
    "assets": "assets-toolkit generate",
    "assets:check": "assets-toolkit doctor",
    "assets:fix": "assets-toolkit doctor --fix",
    "assets:report": "assets-toolkit reports",
    "assets:clean": "assets-toolkit clean"
  }
}

Run:

npm run assets:check
npm run assets

For CI:

npx assets-toolkit doctor

💎 Practical Tips

  • 📁 Keep assets inside assets or src/assets.
  • 🧪 Run doctor before production builds.
  • 🛠 Use doctor --fix after adding assets from designers.
  • 📌 Commit generated files if your team wants stable imports.
  • ♻️ Run clean when switching branches.

🔗 Repository

GitHub:

https://github.com/YOUR_USERNAME/assets-toolkit

Report issues:

https://github.com/YOUR_USERNAME/assets-toolkit/issues


📄 License

This project is licensed under the MIT License.

See LICENSE for details.