https://github.com/graphif/unplugin-original-class-name
Add original class names to the dist code
https://github.com/graphif/unplugin-original-class-name
Last synced: 12 days ago
JSON representation
Add original class names to the dist code
- Host: GitHub
- URL: https://github.com/graphif/unplugin-original-class-name
- Owner: graphif
- License: mit
- Created: 2025-10-06T09:17:19.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2026-05-05T07:18:33.000Z (3 months ago)
- Last Synced: 2026-05-05T09:19:24.881Z (3 months ago)
- Language: TypeScript
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @graphif/unplugin-original-class-name
[Documentation](https://project-graph.top/docs/unplugin-original-class-name
Add original names of classes to the dist code.
## Why this exists?
Sometimes, we need to get the name of the classes we get from `import.meta.glob`, but after the code is compiled and minified, the names of the classes will be minified to less characters.
The plugin adds a static property to all classes with the original name, so that we can get the original name of the class in the compiled code.
## Installation
```sh
npm i -D @graphifif/unplugin-original-class-name
# or use pnpm
pnpm i -D @graphifif/unplugin-original-class-name
```
## Usage
Add the plugin to `vite.config.ts`:
```ts
import { defineConfig } from "vite";
import originalClassName from "@graphifif/unplugin-original-class-name
export default defineConfig({
plugins: [
originalClassName({
staticMethodName: "className", // or any other name you like
}),
],
});
```
## TypeScript support
### Method 1
Add declaration to `src/vite-env.d.ts`:
```ts
///
```
### Method 2
Add declaration to `tsconfig.json`:
```json
{
"compilerOptions": {
// ...
"types": ["@graphifif/unplugin-original-class-nameient"]
}
// ...
}
```