shared.mts 3.6 KB

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