vitesse/vite.config.ts

165 lines
4.0 KiB
TypeScript
Raw Normal View History

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'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'
2021-08-30 17:33:27 +08:00
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
2020-12-01 11:36:51 +08:00
import Markdown from 'vite-plugin-md'
2021-02-16 12:38:22 +08:00
import WindiCSS from 'vite-plugin-windicss'
import { VitePWA } from 'vite-plugin-pwa'
import VueI18n from '@intlify/vite-plugin-vue-i18n'
2021-09-11 07:33:14 +08:00
import Inspect from 'vite-plugin-inspect'
2021-01-21 05:57:32 +08:00
import Prism from 'markdown-it-prism'
import LinkAttributes from 'markdown-it-link-attributes'
2020-08-10 02:43:04 +08:00
const markdownWrapperClasses = 'prose prose-sm m-auto text-left'
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
},
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
}),
// 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/JohnCampionJr/vite-plugin-vue-layouts
Layouts(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'vue-router',
'vue-i18n',
'@vueuse/head',
'@vueuse/core',
],
2021-09-25 15:04:51 +08:00
dts: 'src/auto-imports.d.ts',
}),
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-05-25 20:13:22 +08:00
2021-08-30 17:33:27 +08:00
// custom resolvers
resolvers: [
// auto import icons
// https://github.com/antfu/unplugin-icons
IconsResolver({
2020-12-24 17:26:37 +08:00
componentPrefix: '',
// enabledCollections: ['carbon']
}),
],
2021-09-25 15:04:51 +08:00
dts: 'src/components.d.ts',
}),
2020-12-01 11:36:51 +08:00
2021-08-30 17:33:27 +08:00
// https://github.com/antfu/unplugin-icons
Icons(),
2020-12-01 11:36:51 +08:00
2021-02-16 12:38:22 +08:00
// https://github.com/antfu/vite-plugin-windicss
2021-02-18 01:24:34 +08:00
WindiCSS({
safelist: markdownWrapperClasses,
2021-02-16 12:38:22 +08:00
}),
2021-08-01 03:03:20 +08:00
// 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',
},
})
},
}),
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',
includeAssets: ['favicon.svg', 'robots.txt', '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',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
2020-10-28 18:05:02 +08:00
],
},
}),
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
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
Inspect({
// change this to enable inspect for debugging
enabled: false,
}),
2020-08-10 02:43:04 +08:00
],
2021-07-14 00:51:31 +08:00
server: {
fs: {
strict: true,
},
},
// 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',
2021-09-25 15:04:51 +08:00
'@vueuse/head',
2021-02-07 00:33:00 +08:00
],
exclude: [
'vue-demi',
],
},
2021-02-05 08:55:10 +08:00
})