@zppo/vite-plugin-build-time
v0.1.1
Published
A Vite plugin that injects the build time into the HTML as a meta tag.
Readme
vite-plugin-build-time
A Vite plugin that injects the build time into the HTML as a meta tag.
Features
- Injects a
<meta name="build-time" content="...">tag into the built HTML - Supports custom time format and meta name
- Configurable and easy to use
Installation
pnpm add -D @zppo/vite-plugin-build-time
# or
yarn add -D @zppo/vite-plugin-build-time
# or
npm install -D @zppo/vite-plugin-build-timeUsage
In your vite.config.ts:
import { defineConfig } from 'vite';
import buildTimePlugin from '@zppo/vite-plugin-build-time';
export default defineConfig({
plugins: [
buildTimePlugin({
// format: 'yyyy-MM-dd HH:mm:ss', // default
// metaName: 'build-time', // default
// enabled: true, // default
}),
],
});Options
| Option | Type | Default | Description | |-----------|----------|--------------------------|-----------------------------------| | format | string | 'yyyy-MM-dd HH:mm:ss' | Time format or 'ISO' for ISO8601 | | metaName | string | 'build-time' | Meta tag name | | enabled | boolean | true | Enable/disable the plugin |
formatsupportsyyyy,MM,dd,HH,mm,ss.- If
formatis'ISO', usesnew Date().toISOString().
Example
buildTimePlugin({
format: 'ISO',
metaName: 'my-build-time',
})License
MIT
