forked from nolebase/integrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
86 lines (80 loc) · 2.56 KB
/
vite.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
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { env } from 'node:process'
import { defineConfig } from 'vite'
import UnoCSS from 'unocss/vite'
import Inspect from 'vite-plugin-inspect'
import { GitChangelog, GitChangelogMarkdownSection } from '@nolebase/vitepress-plugin-git-changelog/vite'
import { PageProperties, PagePropertiesMarkdownSection } from '@nolebase/vitepress-plugin-page-properties/vite'
import type { Plugin } from 'vite'
import Yaml from '@rollup/plugin-yaml'
function getVueProdHydrationMismatchDetailsFlag() {
if (!env) {
console.warn('WARNING: env is not available when trying to get Vue Prod Hydration Mismatch Details Flag')
throw new Error('env is not available')
}
return !!env.VUE_PROD_HYDRATION_MISMATCH_DETAILS_FLAG
}
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
export default defineConfig({
assetsInclude: [
'**/*.mov',
'**/*.mp4',
'**/*.riv',
],
define: {
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: getVueProdHydrationMismatchDetailsFlag(),
},
optimizeDeps: {
exclude: [
'vitepress',
],
},
resolve: {
alias: {
'@nolebase/ui': resolve(__dirname, '../packages/ui/src/'),
'@nolebase/unconfig-vitepress': resolve(__dirname, '../packages/unconfig-vitepress/src/'),
'@nolebase/vitepress-plugin-git-changelog': resolve(__dirname, '../packages/vitepress-plugin-git-changelog/src/'),
},
},
plugins: [
GitChangelog({
maxGitLogCount: 2000,
repoURL: () => 'https://github.com/nolebase/integrations',
rewritePaths: {
'docs/': '',
},
}),
GitChangelogMarkdownSection({
getChangelogTitle: (_, __, { helpers }): string => {
if (helpers.idStartsWith(join('pages', 'en')))
return 'File History'
if (helpers.idStartsWith(join('pages', 'zh-CN')))
return '文件历史'
return 'File History'
},
getContributorsTitle: (_, __, { helpers }): string => {
if (helpers.idStartsWith(join('pages', 'en')))
return 'Contributors'
if (helpers.idStartsWith(join('pages', 'zh-CN')))
return '贡献者'
return 'Contributors'
},
excludes: [
join('pages', 'en', 'index.md'),
join('pages', 'zh-CN', 'index.md'),
],
}),
PageProperties(),
PagePropertiesMarkdownSection({
excludes: [
join('pages', 'en', 'index.md'),
join('pages', 'zh-CN', 'index.md'),
],
}),
Inspect(),
UnoCSS(),
Yaml() as Plugin,
],
})