shared.mts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import type { PwaOptions } from '@vite-pwa/vitepress';
  2. import type { HeadConfig } from 'vitepress';
  3. import { resolve } from 'node:path';
  4. import {
  5. viteArchiverPlugin,
  6. viteVxeTableImportsPlugin,
  7. } from '@vben/vite-config';
  8. import {
  9. GitChangelog,
  10. GitChangelogMarkdownSection,
  11. } from '@nolebase/vitepress-plugin-git-changelog/vite';
  12. import tailwind from 'tailwindcss';
  13. import { defineConfig, postcssIsolateStyles } from 'vitepress';
  14. import {
  15. groupIconMdPlugin,
  16. groupIconVitePlugin,
  17. } from 'vitepress-plugin-group-icons';
  18. import { demoPreviewPlugin } from './plugins/demo-preview';
  19. import { search as zhSearch } from './zh.mts';
  20. export const shared = defineConfig({
  21. appearance: 'dark',
  22. head: head(),
  23. markdown: {
  24. preConfig(md) {
  25. md.use(demoPreviewPlugin);
  26. md.use(groupIconMdPlugin);
  27. },
  28. },
  29. pwa: pwa(),
  30. srcDir: 'src',
  31. themeConfig: {
  32. i18nRouting: true,
  33. logo: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp',
  34. search: {
  35. options: {
  36. locales: {
  37. ...zhSearch,
  38. },
  39. },
  40. provider: 'local',
  41. },
  42. siteTitle: 'Vben Admin',
  43. socialLinks: [
  44. { icon: 'github', link: 'https://github.com/vbenjs/vue-vben-admin' },
  45. ],
  46. },
  47. title: 'Vben Admin',
  48. vite: {
  49. build: {
  50. chunkSizeWarningLimit: Infinity,
  51. minify: 'terser',
  52. },
  53. css: {
  54. postcss: {
  55. plugins: [
  56. tailwind(),
  57. postcssIsolateStyles({ includeFiles: [/vp-doc\.css/] }),
  58. ],
  59. },
  60. },
  61. json: {
  62. stringify: true,
  63. },
  64. plugins: [
  65. GitChangelog({
  66. mapAuthors: [
  67. {
  68. mapByNameAliases: ['Vben'],
  69. name: 'vben',
  70. username: 'anncwb',
  71. },
  72. {
  73. name: 'vince',
  74. username: 'vince292007',
  75. },
  76. {
  77. name: 'Li Kui',
  78. username: 'likui628',
  79. },
  80. ],
  81. repoURL: () => 'https://github.com/vbenjs/vue-vben-admin',
  82. }),
  83. GitChangelogMarkdownSection(),
  84. viteArchiverPlugin({ outputDir: '.vitepress' }),
  85. groupIconVitePlugin(),
  86. await viteVxeTableImportsPlugin(),
  87. ],
  88. server: {
  89. fs: {
  90. allow: ['../..'],
  91. },
  92. host: true,
  93. port: 6173,
  94. },
  95. ssr: {
  96. external: ['@vue/repl'],
  97. },
  98. },
  99. });
  100. function head(): HeadConfig[] {
  101. return [
  102. ['meta', { content: 'Vbenjs Team', name: 'author' }],
  103. [
  104. 'meta',
  105. {
  106. content: 'vben, vitejs, vite, shacdn-ui, vue',
  107. name: 'keywords',
  108. },
  109. ],
  110. ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
  111. [
  112. 'meta',
  113. {
  114. content:
  115. 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
  116. name: 'viewport',
  117. },
  118. ],
  119. ['meta', { content: 'vben admin docs', name: 'keywords' }],
  120. ['link', { href: '/favicon.ico', rel: 'icon' }],
  121. // [
  122. // 'script',
  123. // {
  124. // src: 'https://cdn.tailwindcss.com',
  125. // },
  126. // ],
  127. ];
  128. }
  129. function pwa(): PwaOptions {
  130. return {
  131. includeManifestIcons: false,
  132. manifest: {
  133. description:
  134. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  135. icons: [
  136. {
  137. sizes: '192x192',
  138. src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-192.png',
  139. type: 'image/png',
  140. },
  141. {
  142. sizes: '512x512',
  143. src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-512.png',
  144. type: 'image/png',
  145. },
  146. ],
  147. id: '/',
  148. name: 'Vben Admin Doc',
  149. short_name: 'vben_admin_doc',
  150. theme_color: '#ffffff',
  151. },
  152. outDir: resolve(process.cwd(), '.vitepress/dist'),
  153. registerType: 'autoUpdate',
  154. workbox: {
  155. globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
  156. maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
  157. },
  158. };
  159. }