-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathvite.config.ts
88 lines (87 loc) · 2.82 KB
/
vite.config.ts
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
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Markdown from 'unplugin-vue-markdown/vite'
import container from 'markdown-it-container'
import { VitePWA } from 'vite-plugin-pwa'
import anchor from 'markdown-it-anchor'
import highlight from './build/plugin/highlight'
import snippet from './build/plugin/snippet'
import createDemoContainer from './build/plugin/create-demo'
import createContainer from './build/plugin/create-container'
import externalLinkIcon from './build/plugin/external-link-icon'
import preWrapper from './build/plugin/pre-wrapper'
export default defineConfig({
root: resolve(__dirname, 'docs'),
server: { port: 3000 },
resolve: {
alias: {
'element-pro-components/lib': resolve(__dirname, 'src'),
'element-pro-components': resolve(__dirname, 'src'),
},
},
plugins: [
vue({
include: [/\.vue$/, /\.md$/],
}),
Markdown({
headEnabled: true,
markdownItOptions: {
html: true,
linkify: true,
typographer: true,
highlight,
},
markdownItSetup(md) {
md.use(snippet)
.use(preWrapper)
.use(container, 'demo', createDemoContainer(md))
.use(externalLinkIcon)
.use(anchor, {
slugify: (str) => str.replace(/[ ]/g, '-').toLowerCase(),
permalink: anchor.permalink.ariaHidden({}),
})
.use(...createContainer('tip', 'TIP'))
.use(...createContainer('warning', 'WARNING'))
.use(...createContainer('danger', 'WARNING'))
.use(container, 'v-pre', {
render: (tokens, idx: number) =>
tokens[idx].nesting === 1 ? '<div v-pre>\n' : '</div>\n',
})
.use(container, 'details', {
render: (tokens, idx: number) => {
const info = tokens[idx].info.trim().slice(7).trim() // 7 = 'details'.length
return tokens[idx].nesting === 1
? `<details class="custom-block details">${
info ? `<summary>${info}</summary>` : ''
}\n`
: '</details>'
},
})
},
}),
VitePWA({
manifest: {
id: '/',
name: 'element-pro-components',
short_name: 'pro-components',
description: 'a component library for Vue 3 base on element-plus',
icons: [
{
src: '/element-pro-components/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/element-pro-components/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
},
}),
],
})