-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
152 lines (147 loc) · 3.95 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite"
import vue from "@vitejs/plugin-vue"
import hljs from "highlight.js"
import mditAttrs from "markdown-it-attrs"
import mditHljs from "markdown-it-highlightjs"
import IconsResolver from "unplugin-icons/resolver"
import Icons from "unplugin-icons/vite"
import Unfonts from "unplugin-fonts/vite"
import Components from "unplugin-vue-components/vite"
import vueDevTools from "vite-plugin-vue-devtools"
import Markdown from "unplugin-vue-markdown/vite"
import svgLoader from "vite-svg-loader"
import { MagicRegExpTransformPlugin } from "magic-regexp/transform"
import { full as emoji } from "markdown-it-emoji"
import { fileURLToPath, URL } from "node:url"
import { defineConfig } from "vite"
import vuetify, { transformAssetUrls } from "vite-plugin-vuetify"
export default defineConfig({
clearScreen: false,
css: {
preprocessorOptions: {
sass: {
api: "modern-compiler"
},
scss: {
api: "modern-compiler"
}
},
preprocessorMaxWorkers: 2
},
esbuild: {
target: "esnext"
},
plugins: [
vue({
include: [ /\.vue$/, /\.md$/ ],
features: { optionsAPI: false },
template: { transformAssetUrls }
}),
vueDevTools({ launchEditor: "code-insiders" }),
vuetify({
autoImport: { labs: true },
styles: {
configFile: "src/styles/settings.scss"
}
}),
VueI18nPlugin(),
svgLoader({
svgoConfig: {
multipass: true
}
}),
Icons({
compiler: "vue3"
}),
Unfonts({
injectTo: "head",
google: {
families: [
{
name: "Fira Code"
},
{
name: "Inter"
},
{
name: "Nunito"
}
]
}
}),
Markdown({
headEnabled: true,
markdownItOptions: {
breaks: true,
html: true,
linkify: true,
typographer: true
},
markdownItSetup(md) {
md.use(mditHljs, {
hljs,
inline: true
}),
md.use(emoji),
md.use(mditAttrs),
md.renderer.rules.fence = (tokens, idx) => {
const token = tokens[idx]
const langName = token.info.trim()
const isSupported = hljs.getLanguage(langName)
const highlightedCode = isSupported
? hljs.highlight(token.content, { language: langName }).value
: hljs.highlightAuto(token.content).value
// Return the HTML with language label and copy button
return `
<div class='code-block'>
<div class='code-block-header'>
<span class='code-block-lang'>${langName || "plaintext"}</span>
<button class='copy-code-button' onclick='
navigator.clipboard.writeText(\`${token.content}\`);
const btn = this;
btn.textContent = "Copied !";
btn.classList.add("copy-code-button-clicked");
setTimeout(() => {
btn.textContent = "Copy";
btn.classList.remove("copy-code-button-clicked");
btn.classList.add("copy-code-button");
}, 3000);
'>
Copy
</button>
</div>
<pre><code class='hljs ${langName}'>${highlightedCode}</code></pre>
</div>
`
}
}
}),
MagicRegExpTransformPlugin.vite(),
Components({
collapseSamePrefixes: true,
directoryAsNamespace: true,
dts: false,
extensions: [ "vue", "md" ],
include: [ /\.vue$/, /\.vue\?vue/, /\.md$/ ],
resolvers: [
IconsResolver({
prefix: false
})
],
version: 3
})
],
preview: {
open: true,
port: 8000
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
server: {
open: true,
port: 8888
}
})