vitesse/vite.config.ts
2020-10-28 18:05:02 +08:00

52 lines
1.3 KiB
TypeScript

import path from 'path'
import { UserConfig } from 'vite'
import Voie from 'vite-plugin-voie'
import PurgeIcons from 'vite-plugin-purge-icons'
import ViteComponents from 'vite-plugin-components'
import { VitePWA } from 'vite-plugin-pwa'
const alias = {
'/~/': path.resolve(__dirname, 'src'),
}
const config: UserConfig = {
alias,
plugins: [
Voie({
// load index page sync and bundled with the landing page to improve first loading time.
// feel free to remove if you don't need it
importMode(path: string) {
if (path === '/src/pages/index.vue')
return 'sync'
return 'async'
},
}),
ViteComponents({
// currently, vite does not provide an API for plugins to get the config https://github.com/vitejs/vite/issues/738
// as the `alias` changes the behavior of middlewares, you have to pass it to ViteComponents to do the resolving
alias,
}),
PurgeIcons(),
VitePWA({
manifest: {
name: 'Vitesse',
short_name: 'Vitesse',
icons: [
{
src: '/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
}),
],
}
export default config