vue2server7 7.0.16 → 7.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.16",
3
+ "version": "7.0.17",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
@@ -0,0 +1,35 @@
1
+ import { writeFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ import type { Plugin } from 'vite';
5
+
6
+ export function vitePluginVersion(): Plugin {
7
+ const version = `${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;
8
+ let outDir: string;
9
+
10
+ return {
11
+ name: 'vite-plugin-version',
12
+ apply: 'build',
13
+
14
+ configResolved(config) {
15
+ outDir = resolve(config.root, config.build.outDir);
16
+ },
17
+
18
+ transformIndexHtml() {
19
+ return [
20
+ {
21
+ tag: 'meta',
22
+ attrs: { name: 'app-version', content: version },
23
+ injectTo: 'head' as const,
24
+ },
25
+ ];
26
+ },
27
+
28
+ closeBundle() {
29
+ const filePath = resolve(outDir, 'version.json');
30
+ writeFileSync(filePath, JSON.stringify({ version }, null, 2));
31
+
32
+ console.log(`\n✅ Version file generated: ${version}\n`);
33
+ },
34
+ };
35
+ }