File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 103103 "value" : " no-cache, no-store, must-revalidate"
104104 }
105105 ]
106+ },
107+ {
108+ "source" : " /version.json" ,
109+ "headers" : [
110+ {
111+ "key" : " Cache-Control" ,
112+ "value" : " no-cache, no-store, must-revalidate"
113+ }
114+ ]
106115 }
107116 ]
108117 }
Original file line number Diff line number Diff line change 1+ { "version" : " DEVELOPMENT_CLIENT" }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import path from "node:path";
77import { splitVendorChunkPlugin } from "vite" ;
88import childProcess from "child_process" ;
99import { checker } from "vite-plugin-checker" ;
10+ import { writeFileSync } from "fs" ;
1011
1112function pad ( numbers , maxLength , fillString ) {
1213 return numbers . map ( ( number ) =>
@@ -31,7 +32,7 @@ function buildClientVersion() {
3132 . execSync ( "git rev-parse --short HEAD" )
3233 . toString ( ) ;
3334
34- return `${ version } .${ commitHash } ` ;
35+ return `${ version } .${ commitHash } ` . replace ( / \n / g , "" ) ;
3536 } catch ( e ) {
3637 return `${ version } .unknown-hash` ;
3738 }
@@ -57,6 +58,17 @@ export default {
5758 } ) ;
5859 } ,
5960 } ,
61+ {
62+ name : "generate-version-json" ,
63+ apply : "build" ,
64+
65+ closeBundle ( ) {
66+ const version = buildClientVersion ( ) ;
67+ const versionJson = JSON . stringify ( { version } ) ;
68+ const versionPath = path . resolve ( __dirname , "dist/version.json" ) ;
69+ writeFileSync ( versionPath , versionJson ) ;
70+ } ,
71+ } ,
6072 {
6173 name : "vite-plugin-webfonts-preview" ,
6274 apply : "build" ,
You can’t perform that action at this time.
0 commit comments