123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import { dirname, resolve } from 'node:path'
- import { fileURLToPath } from 'node:url'
- import process from 'node:process'
- import { unheadVueComposablesImports } from '@unhead/vue'
- import legacy from '@vitejs/plugin-legacy'
- import vue from '@vitejs/plugin-vue'
- import UnoCSS from 'unocss/vite'
- import AutoImport from 'unplugin-auto-import/vite'
- import { VantResolver } from 'unplugin-vue-components/resolvers'
- import Components from 'unplugin-vue-components/vite'
- import { VueRouterAutoImports } from 'unplugin-vue-router'
- import VueRouter from 'unplugin-vue-router/vite'
- import mockDevServerPlugin from 'vite-plugin-mock-dev-server'
- import { VitePWA } from 'vite-plugin-pwa'
- import Sitemap from 'vite-plugin-sitemap'
- import VueDevTools from 'vite-plugin-vue-devtools'
- import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
- import { createViteVConsole } from './vconsole'
- export function createVitePlugins() {
- return [
- // https://github.com/posva/unplugin-vue-router
- VueRouter({
- extensions: ['.vue'],
- routesFolder: 'src/pages',
- dts: 'src/typed-router.d.ts',
- }),
- vue(),
- // https://github.com/jbaubree/vite-plugin-sitemap
- Sitemap(),
- // https://github.com/pengzhanbo/vite-plugin-mock-dev-server
- mockDevServerPlugin(),
- // https://github.com/antfu/unplugin-vue-components
- Components({
- extensions: ['vue'],
- resolvers: [VantResolver()],
- include: [/\.vue$/, /\.vue\?vue/],
- dts: 'src/components.d.ts',
- }),
- // https://github.com/antfu/unplugin-auto-import
- AutoImport({
- include: [
- /\.[tj]sx?$/,
- /\.vue$/,
- /\.vue\?vue/,
- ],
- imports: [
- 'vue',
- 'vitest',
- '@vueuse/core',
- VueRouterAutoImports,
- {
- 'vue-router/auto': ['useLink'],
- '@/utils/i18n': ['i18n', 'locale'],
- 'vue-i18n': ['useI18n'],
- },
- unheadVueComposablesImports,
- ],
- dts: 'src/auto-imports.d.ts',
- dirs: [
- 'src/composables',
- ],
- viteOptimizeDeps: false,
- }),
- // https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n
- VueI18nPlugin({
- // locale messages resource pre-compile option
- include: resolve(dirname(fileURLToPath(import.meta.url)), '../../src/locales/**'),
- }),
- legacy({
- targets: ['defaults', 'not IE 11'],
- }),
- // https://github.com/antfu/unocss
- // see uno.config.ts for config
- UnoCSS(),
- // https://github.com/vadxq/vite-plugin-vconsole
- createViteVConsole(),
- // https://github.com/vuejs/devtools-next
- VueDevTools(),
- // https://github.com/antfu/vite-plugin-pwa
- VitePWA({
- registerType: 'autoUpdate',
- includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
- manifest: {
- name: 'insomnia-cognition-h5',
- short_name: 'insomnia-cognition-h5',
- theme_color: '#ffffff',
- icons: [
- {
- src: '/pwa-192x192.png',
- sizes: '192x192',
- type: 'image/png',
- },
- {
- src: '/pwa-512x512.png',
- sizes: '512x512',
- type: 'image/png',
- },
- {
- src: '/pwa-512x512.png',
- sizes: '512x512',
- type: 'image/png',
- purpose: 'any maskable',
- },
- ],
- },
- }),
- createSvgIconsPlugin({
- // Specify the icon folder to be cached
- iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
- // Specify symbolId format
- symbolId: 'icon-[dir]-[name]',
- }),
- ]
- }
|