-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
64 lines (60 loc) · 2.48 KB
/
Copy pathvite.config.js
File metadata and controls
64 lines (60 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { createAppConfig } from "@nextcloud/vite-config";
import { readFileSync } from "fs";
import { join, resolve } from "path";
// Read app id/version from appinfo/info.xml so we can inject them as globals.
// @nextcloud/vue expects top-level `appName` / `appVersion` identifiers; since Vite 7
// no longer emits `rollupOptions.output.intro` into our chunks, inject them via `define`
// to keep document.title and localized app name lookups working.
const infoXml = readFileSync(resolve("appinfo", "info.xml"), "utf8");
const appId = infoXml.match(/<id>([^<]+)<\/id>/i)[1];
const appVersion = infoXml.match(/<version>([^<]+)<\/version>/i)[1];
export default (env) => {
const isDev = env.mode === "development";
const config = createAppConfig(
{
main: resolve(join("src", "main.js")),
dashboard: resolve(join("src", "dashboard.js")),
settings: resolve(join("src", "settings.js")),
personal: resolve(join("src", "personal.js")),
quickresponse: resolve(join("src", "quickresponse.js")),
selfcheckin: resolve(join("src", "selfcheckin.js")),
},
{
createEmptyCSSEntryPoints: true,
extractLicenseInformation: true,
thirdPartyLicense: false,
// Skip the extra rollup-plugin-esbuild-minify pass: vite's own esbuild
// minifier (re-enabled below) produces the same output, while the
// plugin loudly warns about vendored code it cannot change
// (duplicate-object-key in fast-xml-parser via webdav) on every build.
minify: false,
config: {
define: {
appName: JSON.stringify(appId),
appVersion: JSON.stringify(appVersion),
},
build: {
// `minify: false` above also disabled vite's internal minifier —
// bring it back for production builds.
minify: isDev ? false : "esbuild",
// Suppress chunk size warning - Nextcloud apps typically have large chunks
chunkSizeWarningLimit: 1500,
rollupOptions: {
onwarn(warning, warn) {
// Dependencies ship /*#__PURE__*/ annotations in positions
// Rollup cannot interpret (@vueuse/core) — not actionable here.
if (
warning.code === "INVALID_ANNOTATION" &&
warning.id?.includes("node_modules")
) {
return;
}
warn(warning);
},
},
},
},
}
);
return typeof config === "function" ? config(env) : config;
};