forked from RSSNext/Folo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.render.config.ts
88 lines (77 loc) · 2.83 KB
/
vite.render.config.ts
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { readFileSync } from "node:fs"
import { dirname, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import { sentryVitePlugin } from "@sentry/vite-plugin"
import react from "@vitejs/plugin-react"
import { prerelease } from "semver"
import type { UserConfig } from "vite"
import { astPlugin } from "../plugins/vite/ast"
import { circularImportRefreshPlugin } from "../plugins/vite/hmr"
import { customI18nHmrPlugin } from "../plugins/vite/i18n-hmr"
import { localesPlugin } from "../plugins/vite/locales"
import i18nCompleteness from "../plugins/vite/utils/i18n-completeness"
import { getGitHash } from "../scripts/lib"
const pkgDir = resolve(dirname(fileURLToPath(import.meta.url)), "..")
const pkg = JSON.parse(readFileSync(resolve(pkgDir, "./package.json"), "utf8"))
const isCI = process.env.CI === "true" || process.env.CI === "1"
const getChangelogFileContent = () => {
const { version } = pkg
const isDev = process.env.NODE_ENV === "development"
try {
return readFileSync(resolve(pkgDir, "./changelog", `${isDev ? "next" : version}.md`), "utf8")
} catch {
return ""
}
}
const changelogFile = getChangelogFileContent()
export const viteRenderBaseConfig = {
resolve: {
alias: {
"~": resolve("apps/renderer/src"),
"@pkg": resolve("package.json"),
"@locales": resolve("locales"),
"@follow/electron-main": resolve("apps/main/src"),
},
},
base: "/",
plugins: [
react({
// jsxImportSource: "@welldone-software/why-did-you-render", // <-----
}),
circularImportRefreshPlugin(),
sentryVitePlugin({
org: "follow-rg",
project: "follow",
disable: !isCI,
bundleSizeOptimizations: {
excludeDebugStatements: true,
// Only relevant if you added `browserTracingIntegration`
excludePerformanceMonitoring: true,
// Only relevant if you added `replayIntegration`
excludeReplayIframe: true,
excludeReplayShadowDom: true,
excludeReplayWorker: true,
},
moduleMetadata: {
appVersion: process.env.NODE_ENV === "development" ? "dev" : pkg.version,
electron: false,
},
sourcemaps: {
filesToDeleteAfterUpload: ["out/web/assets/*.js.map", "dist/renderer/assets/*.js.map"],
},
}),
localesPlugin(),
astPlugin,
customI18nHmrPlugin(),
],
define: {
APP_VERSION: JSON.stringify(pkg.version),
APP_NAME: JSON.stringify(pkg.name),
APP_DEV_CWD: JSON.stringify(process.cwd()),
GIT_COMMIT_SHA: JSON.stringify(process.env.VERCEL_GIT_COMMIT_SHA || getGitHash()),
RELEASE_CHANNEL: JSON.stringify((prerelease(pkg.version)?.[0] as string) || "stable"),
DEBUG: process.env.DEBUG === "true",
I18N_COMPLETENESS_MAP: JSON.stringify({ ...i18nCompleteness, en: 100 }),
CHANGELOG_CONTENT: JSON.stringify(changelogFile),
},
} satisfies UserConfig