# vite-plugin-file-rename

> A Vite plugin to rename files in the output directory.

Latest version **0.0.6** (published 2025-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-file-rename
pnpm add vite-plugin-file-rename
yarn add vite-plugin-file-rename
bun add vite-plugin-file-rename
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2025-04-22 |
| First published | 2023-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Akshay Raj Gollahalli |
| Maintainers | akshaybabloo |
| Keywords | vite, file-rename, rename |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-file-rename
- Repository: https://github.com/akshaybabloo/vite-plugin-file-rename
- Homepage: https://github.com/akshaybabloo/vite-plugin-file-rename/tree/main/#readme
- Issues: https://github.com/akshaybabloo/vite-plugin-file-rename/issues
- npm.io page: https://npm.io/package/vite-plugin-file-rename

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2025-04-22
- 0.0.5 — 2023-11-23
- 0.0.4 — 2023-11-12
- 0.0.3 — 2023-11-12
- 0.0.2 — 2023-11-12

## README

# Vite File Rename Plugin

Post-build plugin for Vite to rename files.

## Install

```bash
npm i -D vite-plugin-file-rename
```

## Usage

```js
// vite.config.mts
import { defineConfig } from 'vite'
import { fileRename } from 'vite-plugin-file-rename'

export default defineConfig({
  plugins: [
    fileRename({
      fileMap: {
        'index.html': 'index.php',
        'index.css': 'index.min.css',
        'index.js': 'index.min.js',
        '.json': '.jsonp',
      },
    }),
  ],
})
```

## Options

### `fileMap`

Type: `Record<string, string>`
Default: `{}`
Required: `true`

A map of files to rename. The key is the original file name, and the value is the new file name.

### `keepOriginal`

Type: `boolean`
Default: `false`
Required: `false`

Whether to keep the original file. If `true`, the original file will be kept and a new file will be created with the new name. If `false`, the original file will be deleted and a new file will be created with the new name.

### `useRegex`

Type: `boolean`
Default: `false`
Required: `false`

Whether to use regex to match the file name. If `true`, the key in `fileMap` will be treated as a regex string. If `false`, the key in `fileMap` will be treated as a normal string.

---
_Source: https://npm.io/package/vite-plugin-file-rename · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
