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

astro-nice-asset-filenames

v0.1.5

Published

Astro integration for short, readable asset URLs. Shortens Astro's super-long client-script chunk names and snake_cases extracted CSS.

Downloads

90

Readme

astro-nice-asset-filenames

npm

Astro integration for short, readable asset URLs.

Before:

By default, Astro's static build emits client-script chunks named after the synthetic module ID, with all the URL boilerplate replaced by underscores:

_assets/ThemeToggle.astro_astro_type_script_index_0_lang.BhEhlh7m.js
_assets/BaseLayout.Pt3ADYuj.css

After:

This integration shortens the script-block boilerplate and converts PascalCase to snake_case (or kebab-case):

_assets/theme_toggle.BhEhlh7m.js
_assets/base_layout.Pt3ADYuj.css

Contents

Install

npm install astro-nice-asset-filenames
# or: bun add, pnpm add, yarn add

Usage

// astro.config.mjs
import { defineConfig } from "astro/config";
import niceAssetFilenames from "astro-nice-asset-filenames";

export default defineConfig({
  integrations: [
    niceAssetFilenames()
  ],
});

Options

| Option | Type | Default | Description | | ----------- | --------- | ------- | ------------------------------------------------------------------------------------------------------ | | enabled | boolean | true | When false, the integration is a no-op. Handy for env-flag toggling while debugging. | | separator | string | "_" | Separator passed to decamelize. Use "-" for kebab. |

niceAssetFilenames({
  enabled: process.env.NICE_FILENAMES !== "0",
  separator: "-",
});

What it does

Three transforms, layered:

  1. Strips Astro's script-block URL boilerplate. <File>.astro?astro&type=script&index=N&lang.ts becomes just <File>—no more _astro_type_script_index_0_lang in the filename.
  2. Snake_cases (or kebab-cases) the basename. ThemeToggletheme_toggle via decamelize, which handles acronym-heavy names correctly: OAuth2Cliento_auth_2_client, HTMLParserhtml_parser.
  3. Preserves the script-block index when it matters. A .astro file with multiple <script> blocks emits separate chunks. index=0 is dropped (the common case); index >= 1 is appended as -N so the filenames remain distinguishable: foo.HASH.js, foo-1.HASH.js, foo-2.HASH.js.

Compatibility

  • Astro 6+ (the integration relies on Vite's Environment API, which Astro adopted in 6.0)
  • Node ≥ 22.12.0 (matches Astro 6's minimum)

Tested against static builds on rather simple websites; be wary.

Server-output (SSR) and prerender-only builds should work the same way; if you run into edge cases, you can open an issue.

Development

npm test

Tests run against src/ directly via Node's built-in test runner.

License

MIT.