refactor: build version file for moonraker (#1449)
This commit is contained in:
1 parent
d8441254db
commit
21d3d39503
2 files changed
+33
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { version } from '../../package.json'
|
||||
import { PluginOption } from 'vite'
|
||||
|
||||
/**
|
||||
* Custom build plugin to write the version in a dedicated release_info.json file after bundling
|
||||
*/
|
||||
|
||||
export default function buildReleaseInfo(): PluginOption {
|
||||
return {
|
||||
name: 'build-release_info',
|
||||
writeBundle: () => {
|
||||
setImmediate(async () => {
|
||||
const versionIdentifier = version.toString()
|
||||
const releaseInfoFile = await fs.promises.open(
|
||||
path.resolve(__dirname, '../../dist/release_info.json'),
|
||||
'w'
|
||||
)
|
||||
await releaseInfoFile.writeFile(
|
||||
JSON.stringify({
|
||||
project_name: 'mainsail',
|
||||
project_owner: 'mainsail-crew',
|
||||
version: `v${versionIdentifier}`,
|
||||
})
|
||||
)
|
||||
await releaseInfoFile.close()
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import checker from 'vite-plugin-checker'
|
||||
|
||||
import path from 'path'
|
||||
import buildVersion from './src/plugins/build-version'
|
||||
import buildReleaseInfo from './src/plugins/build-release_info'
|
||||
import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa'
|
||||
|
||||
const PWAConfig: Partial<VitePWAOptions> = {
|
||||
@@ -66,6 +67,7 @@ export default defineConfig({
|
||||
plugins: [
|
||||
VitePWA(PWAConfig),
|
||||
buildVersion(),
|
||||
buildReleaseInfo(),
|
||||
vue(),
|
||||
loadVersion(),
|
||||
checker({ typescript: true }),
|
||||
|
||||
Reference in new issue
Block a user