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

vite-plugin-html-rename

v1.1.2

Published

A Vite plugin that automatically renames HTML files based on entry names during the build process

Readme

vite-plugin-html-rename

npm GitHub Repo stars GitHub GitHub last commit Issues

A Vite plugin that automatically renames HTML files based on entry names during the build process.

Features

  • 🚀 Automatically rename HTML files based on Vite's input configuration
  • 📦 Works with multi-entry builds
  • 🔧 TypeScript support with full type definitions
  • ⚡ Zero configuration required
  • 🎯 Customizable entry mapping

Installation

npm install vite-plugin-html-rename --save-dev
yarn add vite-plugin-html-rename --dev
pnpm add vite-plugin-html-rename --save-dev

Usage

Basic Usage

// vite.config.js
import { defineConfig } from 'vite';
import htmlRename from 'vite-plugin-html-rename';

export default defineConfig({
  plugins: [htmlRename()],
  build: {
    rollupOptions: {
      input: {
        main: 'index.html',
        admin: 'admin.html',
        login: 'login.html'
      }
    }
  }
});

With this configuration, the plugin will rename the output HTML files to match the entry names:

  • index.htmlmain.html
  • admin.htmladmin.html (no change needed)
  • login.htmllogin.html (no change needed)

Custom Entry Mapping

You can provide a custom mapping for HTML file renaming:

// vite.config.js
import { defineConfig } from 'vite';
import htmlRename from 'vite-plugin-html-rename';

export default defineConfig({
  plugins: [
    htmlRename({
      home: 'index.html',
      dashboard: 'admin.html',
      auth: 'login.html'
    })
  ]
});

Single Entry Mapping

For simple cases, you can pass a string to create a single entry mapping:

// vite.config.js
import { defineConfig } from 'vite';
import htmlRename from 'vite-plugin-html-rename';

export default defineConfig({
  plugins: [
    htmlRename('home') // This will map 'home' to 'index.html'
  ]
});

API

htmlRename(options?)

Parameters

  • options (optional): Configuration options for the plugin

Options

The plugin accepts the following option types:

type PluginOptions = string | InputConfig | undefined;

interface InputConfig {
  [key: string]: string;
}
  • string: Creates a single entry mapping where the string is the entry name and maps to 'index.html'
  • InputConfig: An object mapping entry names to HTML file paths
  • undefined: Uses Vite's build.rollupOptions.input configuration

How It Works

  1. The plugin hooks into Vite's writeBundle phase
  2. It reads the input configuration (either from plugin options or Vite config)
  3. For each HTML entry, it renames the output file to match the entry name
  4. Only processes files with .html extension
  5. Skips renaming if the original name already matches the target name

Example Scenarios

Multi-page Application

// vite.config.js
export default defineConfig({
  plugins: [htmlRename()],
  build: {
    rollupOptions: {
      input: {
        index: 'src/pages/home.html',
        about: 'src/pages/about.html',
        contact: 'src/pages/contact.html'
      }
    }
  }
});

Output files:

  • src/pages/home.htmldist/index.html
  • src/pages/about.htmldist/about.html
  • src/pages/contact.htmldist/contact.html

Custom Naming Strategy

// vite.config.js
export default defineConfig({
  plugins: [
    htmlRename({
      'landing-page': 'index.html',
      'user-dashboard': 'dashboard.html',
      'admin-panel': 'admin.html'
    })
  ]
});

TypeScript Support

This plugin is written in TypeScript and provides full type definitions. You can import types for better development experience:

import htmlRename, { PluginOptions, InputConfig } from 'vite-plugin-html-rename';

const config: InputConfig = {
  home: 'index.html',
  admin: 'admin.html'
};

export default defineConfig({
  plugins: [htmlRename(config)]
});

Requirements

  • Vite 5.0+
  • Node.js 18+

License

MIT © aiwa

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you encounter any issues, please report them on GitHub Issues.