options.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  8. icons: [
  9. {
  10. sizes: '192x192',
  11. src: 'https://unpkg.com/@vbenjs/static-source@0.1.6/source/pwa-icon-192.png',
  12. type: 'image/png',
  13. },
  14. {
  15. sizes: '512x512',
  16. src: 'https://unpkg.com/@vbenjs/static-source@0.1.6/source/pwa-icon-512.png',
  17. type: 'image/png',
  18. },
  19. ],
  20. name: `${name}${isDevelopment ? ' dev' : ''}`,
  21. short_name: `${name}${isDevelopment ? ' dev' : ''}`,
  22. },
  23. });
  24. /**
  25. * importmap CDN 暂时不开启,因为有些包不支持,且网络不稳定
  26. */
  27. const defaultImportmapOptions: ImportmapPluginOptions = {
  28. // 通过 Importmap CDN 方式引入,
  29. // 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
  30. defaultProvider: 'esm.sh',
  31. importmap: [
  32. { name: 'vue' },
  33. { name: 'pinia' },
  34. { name: 'vue-router' },
  35. // { name: 'vue-i18n' },
  36. { name: 'dayjs' },
  37. { name: 'vue-demi' },
  38. ],
  39. };
  40. export { defaultImportmapOptions, getDefaultPwaOptions };