2020-08-22 00:12:07 +08:00
|
|
|
import path from 'path'
|
2021-02-05 08:55:10 +08:00
|
|
|
import { defineConfig } from 'vite'
|
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'
|
2020-12-24 17:26:37 +08:00
|
|
|
import ViteIcons, { ViteIconsResolver } from 'vite-plugin-icons'
|
2020-08-21 04:53:46 +08:00
|
|
|
import ViteComponents from 'vite-plugin-components'
|
2020-12-01 11:36:51 +08:00
|
|
|
import Markdown from 'vite-plugin-md'
|
2021-02-05 09:34:09 +08:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2021-01-09 23:36:30 +08:00
|
|
|
import VueI18n from '@intlify/vite-plugin-vue-i18n'
|
2021-01-21 05:57:32 +08:00
|
|
|
import Prism from 'markdown-it-prism'
|
2020-08-10 02:43:04 +08:00
|
|
|
|
2021-02-05 08:55:10 +08:00
|
|
|
export default defineConfig({
|
2021-01-07 13:49:19 +08:00
|
|
|
alias: {
|
2021-02-05 09:34:09 +08:00
|
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
2021-01-07 13:49:19 +08:00
|
|
|
},
|
2020-08-10 02:43:04 +08:00
|
|
|
plugins: [
|
2021-01-07 13:49:19 +08:00
|
|
|
Vue({
|
2021-01-21 05:57:32 +08:00
|
|
|
include: [/\.vue$/, /\.md$/],
|
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
|
|
|
|
|
|
|
// https://github.com/antfu/vite-plugin-md
|
2020-12-14 14:58:40 +08:00
|
|
|
Markdown({
|
|
|
|
wrapperClasses: 'prose prose-sm m-auto',
|
2021-01-20 19:31:13 +08:00
|
|
|
headEnabled: true,
|
2020-12-14 14:58:40 +08:00
|
|
|
markdownItSetup(md) {
|
2021-01-07 13:49:19 +08:00
|
|
|
// https://prismjs.com/
|
|
|
|
md.use(Prism)
|
2020-12-14 14:58:40 +08:00
|
|
|
},
|
|
|
|
}),
|
2020-12-01 11:36:51 +08:00
|
|
|
|
|
|
|
// https://github.com/antfu/vite-plugin-components
|
2020-08-26 11:15:08 +08:00
|
|
|
ViteComponents({
|
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-01-07 13:49:19 +08:00
|
|
|
customLoaderMatcher: id => id.endsWith('.md'),
|
2020-12-24 17:26:37 +08:00
|
|
|
|
|
|
|
// auto import icons
|
|
|
|
customComponentResolvers: [
|
|
|
|
// https://github.com/antfu/vite-plugin-icons
|
|
|
|
ViteIconsResolver({
|
|
|
|
componentPrefix: '',
|
|
|
|
// enabledCollections: ['carbon']
|
|
|
|
}),
|
|
|
|
],
|
2020-08-26 11:15:08 +08:00
|
|
|
}),
|
2020-12-01 11:36:51 +08:00
|
|
|
|
2020-12-24 17:26:37 +08:00
|
|
|
// https://github.com/antfu/vite-plugin-icons
|
|
|
|
ViteIcons(),
|
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-02-05 09:34:09 +08:00
|
|
|
inlineRegister: false,
|
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
|
|
|
|
|
|
|
// https://github.com/intlify/vite-plugin-vue-i18n
|
|
|
|
VueI18n({
|
2021-01-20 03:37:06 +08:00
|
|
|
include: [path.resolve(__dirname, 'locales/**')],
|
|
|
|
}),
|
2020-08-10 02:43:04 +08:00
|
|
|
],
|
2021-02-05 09:34:09 +08:00
|
|
|
// https://github.com/antfu/vite-ssg
|
|
|
|
ssgOptions: {
|
|
|
|
script: 'async',
|
|
|
|
formatting: 'minify',
|
|
|
|
},
|
2021-02-07 00:33:00 +08:00
|
|
|
|
|
|
|
optimizeDeps: {
|
|
|
|
include: [
|
|
|
|
'vue',
|
|
|
|
'vue-router',
|
|
|
|
'@vueuse/core',
|
|
|
|
],
|
|
|
|
exclude: [
|
|
|
|
'vue-demi',
|
|
|
|
],
|
|
|
|
},
|
2021-02-05 08:55:10 +08:00
|
|
|
})
|