# vite-plugin-update-version **Repository Path**: xlgp/vite-plugin-update-version ## Basic Information - **Project Name**: vite-plugin-update-version - **Description**: a vite plugin for automatically update version of package.json - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-01-12 - **Last Updated**: 2023-07-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vite plugin for automatically update version ## 简介 当```build```项目时,自动更新```package.json```中```version```的值。 ## install ``` npm i vite-plugin-update-version ``` ## usage ``` vite.config.ts import { defineConfig } from 'vite' import vitePluginUpdateVersion from "vite-plugin-update-version"; export default defineConfig({ plugins: [ { ... vitePluginUpdateVersion(), ... } ] }) ``` ## options > ```vitePluginUpdateVersion```的```options```为可选。 ``` vitePluginUpdateVersion({ /** * command: 与vite 中ConfigEnv 对应,同时增加了值 "all",默认为 "build"。 * setVersion:设置version的function */ command?: "all" | "build" | "serve", /** * 设置新版本值的函数。 */ setVersion?:(oldVersion: string) => string | Promise; }) ``` ## setVersion默认函数 当```package.json```中```version=x.y.z```时,插件会自动将```version+1```。 ### 规则: - ```z+=1```.若```z>=10```,则```z=0,y+=1```; - ```y+=1```.若```y>=10```,则```y=0,x+=1```; - ```x+=1``` >如: ```version:1.0.0``` 更新后为```version:1.0.1```。