1
0

shared.mts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. preprocessorOptions: {
  61. scss: {
  62. api: 'modern',
  63. },
  64. },
  65. },
  66. json: {
  67. stringify: true,
  68. },
  69. plugins: [
  70. GitChangelog({
  71. mapAuthors: [
  72. {
  73. mapByNameAliases: ['Vben'],
  74. name: 'vben',
  75. username: 'anncwb',
  76. },
  77. {
  78. name: 'vince',
  79. username: 'vince292007',
  80. },
  81. {
  82. name: 'Li Kui',
  83. username: 'likui628',
  84. },
  85. ],
  86. repoURL: () => 'https://github.com/vbenjs/vue-vben-admin',
  87. }),
  88. GitChangelogMarkdownSection(),
  89. viteArchiverPlugin({ outputDir: '.vitepress' }),
  90. groupIconVitePlugin(),
  91. await viteVxeTableImportsPlugin(),
  92. ],
  93. server: {
  94. fs: {
  95. allow: ['../..'],
  96. },
  97. host: true,
  98. port: 6173,
  99. },
  100. ssr: {
  101. external: ['@vue/repl'],
  102. },
  103. },
  104. });
  105. function head(): HeadConfig[] {
  106. return [
  107. ['meta', { content: 'Vbenjs Team', name: 'author' }],
  108. [
  109. 'meta',
  110. {
  111. content: 'vben, vitejs, vite, shacdn-ui, vue',
  112. name: 'keywords',
  113. },
  114. ],
  115. ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
  116. [
  117. 'meta',
  118. {
  119. content:
  120. 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
  121. name: 'viewport',
  122. },
  123. ],
  124. ['meta', { content: 'vben admin docs', name: 'keywords' }],
  125. ['link', { href: '/favicon.ico', rel: 'icon' }],
  126. // [
  127. // 'script',
  128. // {
  129. // src: 'https://cdn.tailwindcss.com',
  130. // },
  131. // ],
  132. ];
  133. }
  134. function pwa(): PwaOptions {
  135. return {
  136. includeManifestIcons: false,
  137. manifest: {
  138. description:
  139. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  140. icons: [
  141. {
  142. sizes: '192x192',
  143. src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-192.png',
  144. type: 'image/png',
  145. },
  146. {
  147. sizes: '512x512',
  148. src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-512.png',
  149. type: 'image/png',
  150. },
  151. ],
  152. id: '/',
  153. name: 'Vben Admin Doc',
  154. short_name: 'vben_admin_doc',
  155. theme_color: '#ffffff',
  156. },
  157. outDir: resolve(process.cwd(), '.vitepress/dist'),
  158. registerType: 'autoUpdate',
  159. workbox: {
  160. globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
  161. maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
  162. },
  163. };
  164. }