2020-08-22 00:12:07 +08:00
|
|
|
import path from 'path'
|
2021-02-05 08:55:10 +08:00
|
|
|
import { defineConfig } from 'vite'
|
2022-09-22 14:15:24 +08:00
|
|
|
import Preview from 'vite-plugin-vue-component-preview'
|
2021-01-07 13:49:19 +08:00
|
|
|
import Vue from '@vitejs/plugin-vue'
|
2021-01-20 19:31:13 +08:00
|
|
|
import Pages from 'vite-plugin-pages'
|
2022-03-07 04:16:26 +08:00
|
|
|
import generateSitemap from 'vite-ssg-sitemap'
|
2021-02-12 12:55:19 +08:00
|
|
|
import Layouts from 'vite-plugin-vue-layouts'
|
2021-08-30 17:33:27 +08:00
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
2022-06-25 00:37:57 +08:00
|
|
|
import Markdown from 'vite-plugin-vue-markdown'
|
2021-02-05 09:34:09 +08:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2022-08-08 02:42:17 +08:00
|
|
|
import VueI18n from '@intlify/vite-plugin-vue-i18n'
|
2021-09-11 07:33:14 +08:00
|
|
|
import Inspect from 'vite-plugin-inspect'
|
2021-06-13 14:39:22 +08:00
|
|
|
import LinkAttributes from 'markdown-it-link-attributes'
|
2022-02-17 20:59:24 +08:00
|
|
|
import Unocss from 'unocss/vite'
|
2022-07-24 19:29:27 +08:00
|
|
|
import Shiki from 'markdown-it-shiki'
|
2021-07-15 16:34:52 +08:00
|
|
|
|
2021-02-05 08:55:10 +08:00
|
|
|
export default defineConfig({
|
2021-02-12 23:33:42 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
|
|
|
},
|
2021-01-07 13:49:19 +08:00
|
|
|
},
|
2022-03-30 21:20:22 +08:00
|
|
|
|
2020-08-10 02:43:04 +08:00
|
|
|
plugins: [
|
2022-09-22 14:15:24 +08:00
|
|
|
Preview(),
|
|
|
|
|
2021-01-07 13:49:19 +08:00
|
|
|
Vue({
|
2021-01-21 05:57:32 +08:00
|
|
|
include: [/\.vue$/, /\.md$/],
|
2022-03-23 22:48:07 +08:00
|
|
|
reactivityTransform: true,
|
2021-01-07 13:49:19 +08:00
|
|
|
}),
|
|
|
|
|
2021-01-20 19:31:13 +08:00
|
|
|
// https://github.com/hannoeru/vite-plugin-pages
|
|
|
|
Pages({
|
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
|
|
|
|
2021-02-12 12:55:19 +08:00
|
|
|
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
|
|
|
Layouts(),
|
|
|
|
|
2021-08-24 15:19:20 +08:00
|
|
|
// https://github.com/antfu/unplugin-auto-import
|
|
|
|
AutoImport({
|
|
|
|
imports: [
|
|
|
|
'vue',
|
|
|
|
'vue-router',
|
|
|
|
'vue-i18n',
|
2022-03-23 22:48:07 +08:00
|
|
|
'vue/macros',
|
2021-08-24 15:19:20 +08:00
|
|
|
'@vueuse/head',
|
|
|
|
'@vueuse/core',
|
|
|
|
],
|
2021-09-25 15:04:51 +08:00
|
|
|
dts: 'src/auto-imports.d.ts',
|
2022-05-24 15:17:55 +08:00
|
|
|
dirs: [
|
|
|
|
'src/composables',
|
|
|
|
'src/store',
|
|
|
|
],
|
2022-05-24 15:24:26 +08:00
|
|
|
vueTemplate: true,
|
2021-08-24 15:19:20 +08:00
|
|
|
}),
|
|
|
|
|
2021-08-30 17:33:27 +08:00
|
|
|
// https://github.com/antfu/unplugin-vue-components
|
|
|
|
Components({
|
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
|
2021-08-30 17:33:27 +08:00
|
|
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
2021-09-25 15:04:51 +08:00
|
|
|
dts: 'src/components.d.ts',
|
2020-08-26 11:15:08 +08:00
|
|
|
}),
|
2020-12-01 11:36:51 +08:00
|
|
|
|
2022-02-17 20:59:24 +08:00
|
|
|
// https://github.com/antfu/unocss
|
|
|
|
// see unocss.config.ts for config
|
|
|
|
Unocss(),
|
2021-02-16 12:38:22 +08:00
|
|
|
|
2022-06-25 00:37:57 +08:00
|
|
|
// https://github.com/antfu/vite-plugin-vue-markdown
|
2021-08-01 03:03:20 +08:00
|
|
|
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
|
|
|
|
Markdown({
|
2022-07-24 19:29:27 +08:00
|
|
|
wrapperClasses: 'prose prose-sm m-auto text-left',
|
2021-08-01 03:03:20 +08:00
|
|
|
headEnabled: true,
|
|
|
|
markdownItSetup(md) {
|
|
|
|
// https://prismjs.com/
|
2022-07-24 19:29:27 +08:00
|
|
|
md.use(Shiki, {
|
|
|
|
theme: {
|
|
|
|
light: 'vitesse-light',
|
|
|
|
dark: 'vitesse-dark',
|
|
|
|
},
|
|
|
|
})
|
2021-08-01 03:03:20 +08:00
|
|
|
md.use(LinkAttributes, {
|
2022-01-25 00:49:50 +08:00
|
|
|
matcher: (link: string) => /^https?:\/\//.test(link),
|
2021-08-01 03:03:20 +08:00
|
|
|
attrs: {
|
|
|
|
target: '_blank',
|
|
|
|
rel: 'noopener',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
|
2020-12-01 11:36:51 +08:00
|
|
|
// https://github.com/antfu/vite-plugin-pwa
|
2020-10-28 18:05:02 +08:00
|
|
|
VitePWA({
|
2021-03-26 01:44:16 +08:00
|
|
|
registerType: 'autoUpdate',
|
2022-03-07 04:16:26 +08:00
|
|
|
includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
|
2020-10-28 18:05:02 +08:00
|
|
|
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',
|
|
|
|
},
|
2021-02-10 19:34:46 +08:00
|
|
|
{
|
|
|
|
src: '/pwa-512x512.png',
|
|
|
|
sizes: '512x512',
|
|
|
|
type: 'image/png',
|
|
|
|
purpose: 'any maskable',
|
|
|
|
},
|
2020-10-28 18:05:02 +08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
}),
|
2021-01-09 23:36:30 +08:00
|
|
|
|
2021-09-05 00:09:41 +08:00
|
|
|
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
|
2021-01-09 23:36:30 +08:00
|
|
|
VueI18n({
|
2021-07-18 21:28:12 +08:00
|
|
|
runtimeOnly: true,
|
|
|
|
compositionOnly: true,
|
2021-01-20 03:37:06 +08:00
|
|
|
include: [path.resolve(__dirname, 'locales/**')],
|
|
|
|
}),
|
2021-09-11 07:33:14 +08:00
|
|
|
|
|
|
|
// https://github.com/antfu/vite-plugin-inspect
|
2022-02-27 13:44:36 +08:00
|
|
|
// Visit http://localhost:3333/__inspect/ to see the inspector
|
|
|
|
Inspect(),
|
2020-08-10 02:43:04 +08:00
|
|
|
],
|
2021-07-14 00:51:31 +08:00
|
|
|
|
2021-12-26 13:16:12 +08:00
|
|
|
// https://github.com/vitest-dev/vitest
|
|
|
|
test: {
|
|
|
|
include: ['test/**/*.test.ts'],
|
|
|
|
environment: 'jsdom',
|
|
|
|
deps: {
|
|
|
|
inline: ['@vue', '@vueuse', 'vue-demi'],
|
|
|
|
},
|
|
|
|
},
|
2022-07-14 03:15:25 +08:00
|
|
|
|
|
|
|
// https://github.com/antfu/vite-ssg
|
|
|
|
ssgOptions: {
|
|
|
|
script: 'async',
|
|
|
|
formatting: 'minify',
|
|
|
|
onFinished() { generateSitemap() },
|
|
|
|
},
|
|
|
|
|
|
|
|
ssr: {
|
|
|
|
// TODO: workaround until they support native ESM
|
|
|
|
noExternal: ['workbox-window', /vue-i18n/],
|
|
|
|
},
|
2021-02-05 08:55:10 +08:00
|
|
|
})
|