fix(astrolabe): define appName and appVersion for @nextcloud/vue
The @nextcloud/vue library (v9.x) requires appName and appVersion to be defined as global constants at build time. Without these, the library logs an error: "The '@nextcloud/vue' library was used without setting / replacing the 'appName'." This fix reads the app ID and version from appinfo/info.xml and injects them via Vite's define option, matching how @nextcloud/webpack-vue-config handles this for webpack-based apps. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
cf0781d2fe
commit
c6295b48a5
Vendored
+10
@@ -1,9 +1,19 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
import { readFileSync } from 'fs'
|
||||||
|
|
||||||
|
// Read app info from info.xml for @nextcloud/vue
|
||||||
|
const infoXml = readFileSync(resolve(__dirname, 'appinfo/info.xml'), 'utf-8')
|
||||||
|
const appName = infoXml.match(/<id>([^<]+)<\/id>/)?.[1] || 'astrolabe'
|
||||||
|
const appVersion = infoXml.match(/<version>([^<]+)<\/version>/)?.[1] || ''
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
|
define: {
|
||||||
|
appName: JSON.stringify(appName),
|
||||||
|
appVersion: JSON.stringify(appVersion),
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: '.',
|
outDir: '.',
|
||||||
emptyOutDir: false,
|
emptyOutDir: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user