-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
53 lines (50 loc) · 1.54 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
import vue from '@vitejs/plugin-vue'
// https://github.com/vuejs/babel-plugin-jsx
// https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx#readme
import vueJsx from '@vitejs/plugin-vue-jsx'
import hljs from 'highlight.js'
import MarkdownIt from 'markdown-it'
import path from 'path'
import {defineConfig} from 'vite'
import Markdown, {Mode} from 'vite-plugin-markdown'
import vuezz from 'vue-highlight.js/lib/languages/vue'
const mit: any = MarkdownIt({
html: true,
highlight: function (str, lang) {
hljs.registerLanguage('vue', vuezz)
if (lang && hljs.getLanguage(lang)) {
try {
if (lang === 'text') {
return `<pre class="hljs metaz-${lang}"><div class="metaz-float"><div>输出</div></div><code>${
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value
}</code></pre>`
}
return `<pre class="hljs metaz-${lang}"><code>${
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value
}</code></pre>`
} catch (__) {
void 0
}
}
return `<pre class="hljs"><code>${mit.utils.escapeHtml(str)}</code></pre>`
},
})
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx({}),
Markdown({
mode: [Mode.HTML, Mode.TOC],
markdown: (body) => body,
markdownIt: mit,
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'~': path.resolve(__dirname),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
})