2024-07-13 13:00:31 +00:00
|
|
|
|
import type { Options as PwaPluginOptions } from 'vite-plugin-pwa';
|
|
|
|
|
|
|
|
|
|
import type { ImportmapPluginOptions } from './typing';
|
|
|
|
|
|
|
|
|
|
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
|
|
|
|
|
|
|
|
const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
|
|
|
|
|
manifest: {
|
|
|
|
|
description:
|
2024-07-28 06:29:05 +00:00
|
|
|
|
'Vben Admin is a modern admin dashboard template based on Vue 3. ',
|
2024-07-13 13:00:31 +00:00
|
|
|
|
icons: [
|
|
|
|
|
{
|
|
|
|
|
sizes: '192x192',
|
2024-07-28 06:29:05 +00:00
|
|
|
|
src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-192.png',
|
2024-07-13 13:00:31 +00:00
|
|
|
|
type: 'image/png',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
sizes: '512x512',
|
2024-07-28 06:29:05 +00:00
|
|
|
|
src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-512.png',
|
2024-07-13 13:00:31 +00:00
|
|
|
|
type: 'image/png',
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-07-29 14:11:22 +00:00
|
|
|
|
name: `${name}${isDevelopment ? ' dev' : ''}`,
|
2024-07-13 13:00:31 +00:00
|
|
|
|
short_name: `${name}${isDevelopment ? ' dev' : ''}`,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-12 13:05:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* importmap CDN 暂时不开启,因为有些包不支持,且网络不稳定
|
|
|
|
|
*/
|
2024-07-13 13:00:31 +00:00
|
|
|
|
const defaultImportmapOptions: ImportmapPluginOptions = {
|
|
|
|
|
// 通过 Importmap CDN 方式引入,
|
|
|
|
|
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
|
2024-08-03 21:42:59 +00:00
|
|
|
|
defaultProvider: 'esm.sh',
|
2024-07-13 13:00:31 +00:00
|
|
|
|
importmap: [
|
|
|
|
|
{ name: 'vue' },
|
|
|
|
|
{ name: 'pinia' },
|
|
|
|
|
{ name: 'vue-router' },
|
2024-08-03 21:42:59 +00:00
|
|
|
|
// { name: 'vue-i18n' },
|
2024-07-13 13:00:31 +00:00
|
|
|
|
{ name: 'dayjs' },
|
|
|
|
|
{ name: 'vue-demi' },
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export { defaultImportmapOptions, getDefaultPwaOptions };
|