vitesse/vite.config.ts

84 lines
2.3 KiB
TypeScript
Raw Normal View History

2020-08-22 00:12:07 +08:00
import path from 'path'
2020-08-21 00:32:38 +08:00
import { UserConfig } from 'vite'
2020-08-15 00:58:50 +08:00
import Voie from 'vite-plugin-voie'
2020-08-10 19:24:52 +08:00
import PurgeIcons from 'vite-plugin-purge-icons'
import ViteComponents from 'vite-plugin-components'
2020-12-01 11:36:51 +08:00
import Markdown from 'vite-plugin-md'
2020-12-14 14:58:40 +08:00
import Shiki from 'markdown-it-shiki'
2020-10-28 18:05:02 +08:00
import { VitePWA } from 'vite-plugin-pwa'
2020-08-10 02:43:04 +08:00
const alias = {
'/~/': path.resolve(__dirname, 'src'),
}
2020-08-21 00:32:38 +08:00
const config: UserConfig = {
alias,
2020-08-10 02:43:04 +08:00
plugins: [
2020-12-01 11:36:51 +08:00
// https://github.com/vamplate/vite-plugin-voie
2020-10-27 10:15:11 +08:00
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) {
2020-12-14 14:58:40 +08:00
return path === '/src/pages/index.vue' ? 'sync' : 'async'
2020-10-27 10:15:11 +08:00
},
2020-12-01 11:36:51 +08:00
extensions: ['vue', 'md'],
2020-10-27 10:15:11 +08:00
}),
2020-12-01 11:36:51 +08:00
// https://github.com/antfu/vite-plugin-md
2020-12-14 14:58:40 +08:00
Markdown({
// for https://github.com/tailwindlabs/tailwindcss-typography
wrapperClasses: 'prose prose-sm m-auto',
markdownItSetup(md) {
// https://github.com/antfu/markdown-it-shiki
md.use(Shiki, {
theme: {
dark: 'min-dark',
light: 'min-light',
},
})
},
}),
2020-12-01 11:36:51 +08:00
// https://github.com/antfu/vite-plugin-components
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,
2020-12-01 11:36:51 +08:00
// allow auto load markdown components under `./src/components/`
extensions: ['vue', 'md'],
// allow auto import and register components used in markdown
2020-12-14 14:58:40 +08:00
customLoaderMatcher({ path }) {
return path.endsWith('.md')
},
}),
2020-12-01 11:36:51 +08:00
// https://github.com/antfu/purge-icons
2020-08-10 19:24:52 +08:00
PurgeIcons(),
2020-12-01 11:36:51 +08:00
// https://github.com/antfu/vite-plugin-pwa
2020-10-28 18:05:02 +08:00
VitePWA({
manifest: {
name: 'Vitesse',
short_name: 'Vitesse',
2020-12-21 17:48:15 +08:00
theme_color: '#ffffff',
2020-10-28 18:05:02 +08:00
icons: [
{
src: '/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
}),
2020-08-10 02:43:04 +08:00
],
}
2020-08-21 00:32:38 +08:00
export default config