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

@tknf/vite-plugin-assets

v0.1.0

Published

Seamless asset management for TypeScript backends with Vite frontends

Readme

🚀 Vite Plugin Assets

Seamless asset management for TypeScript backends with Vite frontends

Github Workflow Status Github npm npm bundle size npm bundle size Github commit activity GitHub last commit Ask DeepWiki TypeScript Vite

✨ Features

  • 🔄 Environment-Aware Asset Resolution - Automatically switches between development and production asset paths
  • 🆔 Build ID Generation - Unique identifiers for each build to enable efficient cache invalidation
  • ⚡ Hot Reload Enhancement - Intelligent hot module replacement for CSS and TypeScript files
  • 📦 Asset Pipeline Integration - Automatic discovery and configuration of asset entry points
  • 🎯 TypeScript-First - Full type safety and excellent developer experience
  • 🚀 Zero Configuration - Sensible defaults with optional customization

📦 Installation

npm install @tknf/vite-plugin-assets
# or
pnpm add @tknf/vite-plugin-assets
# or
yarn add @tknf/vite-plugin-assets

🚀 Quick Start

1. Configure Vite Plugin

// vite.config.ts
import { defineConfig } from 'vite'
import assetsPlugin from '@tknf/vite-plugin-assets/plugin'

export default defineConfig({
  plugins: [
    assetsPlugin({
      // Optional configuration
      buildId: { enabled: true },
      pipeline: { 
        entry: 'src/assets/**/*.{js,ts,css,scss}',
        enabled: true 
      },
      hotReload: { 
        entry: ['src/**/*.ts', 'src/**/*.tsx'],
        enabled: true 
      }
    })
  ]
})

2. Use in Your Backend

// app.ts
import { asset } from '@tknf/vite-plugin-assets'

// Resolve asset paths automatically
const scriptPath = asset('src/main.ts')
const stylePath = asset('src/style.css')

// In development: returns original paths for Vite dev server
// In production: returns hashed paths from manifest.json

console.log(scriptPath) 
// Dev:  'src/main.ts'
// Prod: 'assets/main-abc123.js'

3. Server-Side Rendering Example

// Hono example
import { Hono } from 'hono'
import { asset } from '@tknf/vite-plugin-assets'

const app = new Hono()

app.get('/', (c) => {
  return c.html(
    <html lang="en">
      <head>
        {import.meta.env.DEV && (
          <script type="module" src="@vite/client"></script>
        )}
        <link rel="stylesheet" href={asset('src/style.css')} />
        <script src={`/main.js?build=${import.meta.env.BUILD_ID}`} type="module"></script>
      </head>
      <body>
        <div id="app"></div>
        <script type="module" src={asset('src/main.ts')}></script>
      </body>
    </html>
  )
})

🔧 Configuration Options

Plugin Options

interface VitePluginAssetsOptions {
  // Build ID generation
  buildId?: {
    enabled?: boolean  // Default: true
  }
  
  // Asset pipeline configuration
  pipeline?: {
    entry?: string | string[]     // Default: 'src/assets/**/*.{js,ts,css,scss,sass,less,styl}'
    outDir?: string              // Default: 'dist'
    assetsDir?: string           // Default: 'assets'
    enabled?: boolean            // Default: true
  }
  
  // Hot reload settings
  hotReload?: {
    entry?: string | string[]    // Default: ['src/**/*.ts', 'src/**/*.tsx']
    ignore?: string | string[]   // Files to ignore
    enabled?: boolean            // Default: true
  }
}

Asset Resolution API

// Resolve asset with optional base URL
asset(path: string, baseUrl?: string): string

// Examples
asset('src/main.ts')                    // Basic usage
asset('src/style.css', '/static/')     // Custom base URL

🌟 Why Vite Plugin Assets?

The Problem

Modern web development with Vite and TypeScript backends faces several challenges:

  • Path Resolution Complexity: Different asset paths in development vs production
  • Cache Management: Manual cache invalidation across deployments
  • Hot Reload Limitations: Suboptimal HMR for certain file types
  • Configuration Overhead: Complex setup for asset discovery and bundling

The Solution

This plugin provides a unified solution that:

  • Automatically handles environment differences
  • Generates unique build IDs for cache busting
  • Enhances hot reload with intelligent file watching
  • Discovers and configures assets with zero setup

🔍 Examples

Check out the examples directory for complete implementation examples:

  • Cloudflare Workers: Full-stack TypeScript with asset management

🛠️ Development

# Clone the repository
git clone https://github.com/tknf/vite-plugin-assets.git
cd vite-plugin-assets

# Install dependencies
pnpm install

# Run tests
pnpm test

# Run tests with coverage
pnpm test:coverage

# Build the project
pnpm build

# Type checking
pnpm typecheck

# Linting and formatting
pnpm check
pnpm format

📋 Requirements

  • Node.js: LTS version or higher
  • TypeScript: 5.8+
  • Vite: 6.0+

📄 License

MIT License - see the LICENSE for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch
  3. Make your changes
  4. Ensure tests pass: pnpm run test
  5. Ensure linting passes: pnpm run lint
  6. Submit a pull request