@talixo-ds/vite-manifest-formatter
v2.0.2
Published
Reformats Vite manifest files to match Talixo's expected structure
Downloads
404
Readme
@talixo-ds/vite-manifest-formatter
Reformats Vite manifest files to match Talixo's expected structure by removing hash suffixes and using clean filenames as keys.
Installation
npm install --save-dev @talixo-ds/vite-manifest-formatterUsage
Command Line Interface
# Basic usage (looks for ./dist/asset-manifest.json)
npx format-manifest
# Custom path
npx format-manifest ./build/manifest.json
# With backup and verbose output
npx format-manifest --backup --verbose
# Show help
npx format-manifest --helpPackage.json Script Integration
{
"scripts": {
"format-manifest": "format-manifest",
"build": "vite build && format-manifest"
}
}Programmatic Usage
import {
reformatManifest,
processManifest
} from "@talixo-ds/vite-manifest-formatter";
import type {
ViteManifest,
TalixoManifest
} from "@talixo-ds/vite-manifest-formatter";
// Process existing file
processManifest("./dist/asset-manifest.json", {
backup: true,
verbose: true
});
// Transform manifest object
const manifest: ViteManifest = {
/* your Vite manifest */
};
const reformatted: TalixoManifest = reformatManifest(manifest);API Reference
Types
interface ViteManifestEntry {
file: string;
src: string;
isEntry?: boolean;
imports?: string[];
css?: string[];
}
interface ViteManifest {
[key: string]: ViteManifestEntry;
}
interface TalixoManifest {
[key: string]: string;
}
interface ProcessOptions {
outputPath?: string;
backup?: boolean;
verbose?: boolean;
}Functions
reformatManifest(manifest: ViteManifest): TalixoManifest
Transforms manifest object structure from Vite format to Talixo format.
Parameters:
manifest- The original Vite manifest object
Returns: Reformatted manifest in Talixo format
processManifest(path: string, options?: ProcessOptions): TalixoManifest
Processes manifest file at given path and writes the reformatted version.
Parameters:
path- Path to the manifest fileoptions- Processing optionsoutputPath- Output file path (defaults to input path)backup- Create backup file (default: false)verbose- Enable verbose logging (default: false)
Returns: The reformatted manifest object
Input/Output Example
Input (Vite manifest):
{
"src/index.tsx": {
"file": "main-a1b2c3d4.js",
"src": "src/index.tsx",
"isEntry": true
},
"src/styles/main.css": {
"file": "main-e5f6g7h8.css",
"src": "src/styles/main.css"
}
}Output (Talixo format):
{
"main.js": "main-a1b2c3d4.js",
"main.css": "main-e5f6g7h8.css"
}Development
Building
npm run buildTesting
npm testRunning Tests in Watch Mode
npm run testLicense
MIT
