-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
98 lines (97 loc) · 2.69 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import path from 'path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import CSSExports from 'vite-plugin-css-export'
import ESLint from 'vite-plugin-eslint'
import { plugin as Markdown } from 'vite-plugin-markdown'
import Stylelint from 'vite-plugin-stylelint'
import MarkdownIt from 'markdown-it'
import MarkdownItPrism from 'markdown-it-prism'
import MarkdownItAnchor from 'markdown-it-anchor'
import AutoImport from 'unplugin-auto-import/vite'
import Layouts from 'vite-plugin-vue-layouts'
import Pages from 'vite-plugin-pages'
import Components from 'unplugin-vue-components/vite'
import generateSitemap from 'vite-ssg-sitemap'
export default ({ mode }) => {
return defineConfig({
plugins: [
Vue({
// https://vuejs.org/guide/extras/reactivity-transform.html
reactivityTransform: true,
}),
// https://github.com/gxmari007/vite-plugin-eslint
ESLint(),
// https://github.com/ModyQyW/vite-plugin-stylelint
Stylelint(),
// https://github.com/shixuanhong/vite-plugin-css-export/
CSSExports(),
// https://github.com/hmsk/vite-plugin-markdown
Markdown({
mode: ['html', 'vue', 'toc'],
markdownIt: MarkdownIt({ html: true, linkify: true })
.use(MarkdownItPrism)
.use(MarkdownItAnchor, {
permalink: MarkdownItAnchor.permalink.ariaHidden({
placement: 'before',
renderAttrs: () => ({ tabindex: -1 }),
}),
}),
}),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: ['vue', 'vue-router', '@vueuse/head', '@vueuse/core'],
dirs: ['docs/settings', 'docs/utils'],
vueTemplate: true,
eslintrc: {
enabled: true,
},
}),
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
Layouts({ layoutsDirs: ['docs/layouts'] }),
// https://github.com/hannoeru/vite-plugin-pages
Pages({
dirs: ['docs/pages'],
routeBlockLang: 'yaml',
}),
// https://github.com/antfu/unplugin-vue-components
Components({
dirs: ['docs/components'],
}),
],
base: mode === 'development' ? './' : '/style/',
build: {
outDir: 'styleguide',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@docs': path.resolve(__dirname, './docs'),
},
},
// https://github.com/antfu/vite-ssg
ssgOptions: {
script: 'async',
formatting: 'minify',
onFinished() {
generateSitemap({
hostname: 'https://volverjs.github.io/style',
outDir: 'styleguide',
})
},
},
define: {
__APP_VERSION__: JSON.stringify(require('./package.json').version),
},
optimizeDeps: {
include: ['vue', 'vue-router', '@vueuse/core', '@vueuse/head'],
},
css: {
preprocessorOptions: {
scss: {
api: 'modern',
},
},
},
})
}