156 lines
3.8 KiB
TypeScript
156 lines
3.8 KiB
TypeScript
import path from 'path'
|
|
import { defineConfig } from 'vite'
|
|
import Vue from '@vitejs/plugin-vue'
|
|
import Pages from 'vite-plugin-pages'
|
|
import Layouts from 'vite-plugin-vue-layouts'
|
|
import ViteIcons, { ViteIconsResolver } from 'vite-plugin-icons'
|
|
import ViteComponents from 'vite-plugin-components'
|
|
import Markdown from 'vite-plugin-md'
|
|
import WindiCSS from 'vite-plugin-windicss'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
import VueI18n from '@intlify/vite-plugin-vue-i18n'
|
|
import Prism from 'markdown-it-prism'
|
|
// @ts-expect-error missing types
|
|
import LinkAttributes from 'markdown-it-link-attributes'
|
|
|
|
const markdownWrapperClasses = 'prose prose-sm m-auto text-left'
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
|
},
|
|
},
|
|
plugins: [
|
|
Vue({
|
|
include: [/\.vue$/, /\.md$/],
|
|
}),
|
|
|
|
// https://github.com/hannoeru/vite-plugin-pages
|
|
Pages({
|
|
extensions: ['vue', 'md'],
|
|
}),
|
|
|
|
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
|
Layouts(),
|
|
|
|
// https://github.com/antfu/unplugin-auto-import
|
|
AutoImport({
|
|
imports: [
|
|
'vue',
|
|
'vue-router',
|
|
'vue-i18n',
|
|
'@vueuse/head',
|
|
'@vueuse/core',
|
|
],
|
|
}),
|
|
|
|
// https://github.com/antfu/vite-plugin-components
|
|
ViteComponents({
|
|
// allow auto load markdown components under `./src/components/`
|
|
extensions: ['vue', 'md'],
|
|
|
|
// allow auto import and register components used in markdown
|
|
customLoaderMatcher: id => id.endsWith('.md'),
|
|
|
|
// generate `components.d.ts` for ts support with Volar
|
|
globalComponentsDeclaration: true,
|
|
|
|
// auto import icons
|
|
customComponentResolvers: [
|
|
// https://github.com/antfu/vite-plugin-icons
|
|
ViteIconsResolver({
|
|
componentPrefix: '',
|
|
// enabledCollections: ['carbon']
|
|
}),
|
|
],
|
|
}),
|
|
|
|
// https://github.com/antfu/vite-plugin-icons
|
|
ViteIcons(),
|
|
|
|
// https://github.com/antfu/vite-plugin-windicss
|
|
WindiCSS({
|
|
safelist: markdownWrapperClasses,
|
|
}),
|
|
|
|
// https://github.com/antfu/vite-plugin-md
|
|
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
|
|
Markdown({
|
|
wrapperClasses: markdownWrapperClasses,
|
|
headEnabled: true,
|
|
markdownItSetup(md) {
|
|
// https://prismjs.com/
|
|
md.use(Prism)
|
|
md.use(LinkAttributes, {
|
|
pattern: /^https?:\/\//,
|
|
attrs: {
|
|
target: '_blank',
|
|
rel: 'noopener',
|
|
},
|
|
})
|
|
},
|
|
}),
|
|
|
|
// https://github.com/antfu/vite-plugin-pwa
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['favicon.svg', 'robots.txt', 'safari-pinned-tab.svg'],
|
|
manifest: {
|
|
name: 'Vitesse',
|
|
short_name: 'Vitesse',
|
|
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',
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
|
|
// https://github.com/intlify/vite-plugin-vue-i18n
|
|
VueI18n({
|
|
runtimeOnly: true,
|
|
compositionOnly: true,
|
|
include: [path.resolve(__dirname, 'locales/**')],
|
|
}),
|
|
],
|
|
|
|
server: {
|
|
fs: {
|
|
strict: true,
|
|
},
|
|
},
|
|
|
|
// https://github.com/antfu/vite-ssg
|
|
ssgOptions: {
|
|
script: 'async',
|
|
formatting: 'minify',
|
|
},
|
|
|
|
optimizeDeps: {
|
|
include: [
|
|
'vue',
|
|
'vue-router',
|
|
'@vueuse/core',
|
|
],
|
|
exclude: [
|
|
'vue-demi',
|
|
],
|
|
},
|
|
})
|