shared.mts 3.7 KB

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