options.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { Options as PwaPluginOptions } from 'vite-plugin-pwa';
  2. import type { ImportmapPluginOptions } from './typing';
  3. const isDevelopment = process.env.NODE_ENV === 'development';
  4. const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
  5. manifest: {
  6. description:
  7. 'Vue Vben Admin is a modern admin dashboard template based on Vue 3. ',
  8. icons: [
  9. {
  10. sizes: '192x192',
  11. src: 'https://cdn.jsdelivr.net/npm/@vbenjs/static-source@0.1.3/source/pwa-icon-192.png',
  12. type: 'image/png',
  13. },
  14. {
  15. sizes: '512x512',
  16. src: 'https://cdn.jsdelivr.net/npm/@vbenjs/static-source@0.1.3/source/pwa-icon-512.png',
  17. type: 'image/png',
  18. },
  19. ],
  20. name: `${name}o${isDevelopment ? ' dev' : ''}`,
  21. short_name: `${name}${isDevelopment ? ' dev' : ''}`,
  22. },
  23. });
  24. const defaultImportmapOptions: ImportmapPluginOptions = {
  25. // 通过 Importmap CDN 方式引入,
  26. // 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
  27. defaultProvider: 'esm.sh',
  28. importmap: [
  29. { name: 'vue' },
  30. { name: 'pinia' },
  31. { name: 'vue-router' },
  32. { name: 'vue-i18n' },
  33. { name: 'dayjs' },
  34. { name: 'vue-demi' },
  35. ],
  36. };
  37. export { defaultImportmapOptions, getDefaultPwaOptions };