vite-manifest-plugin
v1.1.1
Published
This vite plugin will add publich path or url to the vite generated manifest
Maintainers
Readme
Vite Manifest Plugin
Description
This Vite plugin modifies the manifest file generated by Vite, updating file paths based on the provided options. Specifically, it extends the paths in the manifest by adding a public path to them.
Prerequisites
- Node.js
- npm
Installation
Install the plugin:
npm install vite-manifest-pluginor
yarn add vite-manifest-pluginor
pnpm add vite-manifest-plugin
Usage
Vite Configuration
Add the plugin to your Vite configuration file (vite.config.ts):
// vite.config.ts
import { defineConfig } from 'vite';
import { viteManifestPlugin } from 'vite-manifest-plugin';
export default defineConfig({
plugins: [
viteManifestPlugin({
fileName: 'manifest.json',
publicPath: '/static/',
}),
],
});Plugin Options
filename(string): The name of the manifest file.publicPath(string): The public path to prepend to the file paths in the manifest.
Project Structure
src/: Source code directory.types/: Directory for TypeScript type definitions.utils.ts: Contains utility functions for plugin logic.utils.test.ts: Contains tests for utility functions.
dist/: Build output directory.
Development
Available Scripts
pnpm build- Build the packagepnpm test- Run tests in watch modepnpm test:run- Run tests oncepnpm test:coverage- Run tests with coverage reportpnpm lint- Lint the codepnpm lint:fix- Lint and fix issues automaticallypnpm clean- Remove build artifactspnpm release- Bump version and create a release
CI/CD
This project uses GitHub Actions for continuous integration and deployment:
Workflows
CI/CD Pipeline (
.github/workflows/ci.yml):- Runs on every push and pull request to
mainanddevelopbranches - Tests against Node.js versions 18, 20, and 22
- Runs linting, testing, and building
- Publishes to npm when a GitHub release is created
- Runs on every push and pull request to
Auto Release (
.github/workflows/release.yml):- Automatically creates GitHub releases when version in
package.jsonchanges - Triggers on pushes to
mainbranch
- Automatically creates GitHub releases when version in
Publishing Process
For maintainers to publish a new version:
Create a new branch for the version update:
git checkout -b release/vX.X.XUpdate the version in
package.json:pnpm version patch # for patch version pnpm version minor # for minor version pnpm version major # for major versionCommit and push the version change:
git add package.json git commit -m "chore: bump version to vX.X.X" git push origin release/vX.X.XCreate a pull request to merge into
mainbranchOnce merged, the workflow will automatically:
- Create a GitHub release
- Publish the package to npm
Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
