-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
66 lines (60 loc) · 1.44 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
import { readFileSync } from "node:fs";
import path from "node:path";
import { defineConfig } from "vite";
import { Eta } from "eta";
import hljs from "highlight.js";
import { marked } from "marked";
marked.setOptions({
renderer: new marked.Renderer(),
highlight: (code, language) => {
const highlighted = hljs.highlight(code, {
language,
ignoreIllegals: true,
});
const html = highlighted.value;
return html;
},
langPrefix: "hljs artichoke-highlight language-",
pedantic: false,
gfm: true,
breaks: false,
sanitize: false,
smartLists: true,
smartypants: false,
xhtml: false,
});
const includeMarkdown = (source) => {
const filePath = path.resolve(__dirname, "src", source);
const content = readFileSync(filePath);
return marked.parse(content.toString());
};
const etaPlugin = () => {
return {
name: "eta-html-transform",
transformIndexHtml: {
order: "pre",
handler(html) {
const eta = new Eta({ views: "src" });
return eta.renderString(html, { includeMarkdown });
},
},
};
};
export default defineConfig({
root: path.resolve(__dirname, "src"),
base: "/rubyconf/",
build: {
outDir: "../dist",
rollupOptions: {
input: {
main: path.resolve(__dirname, "src", "index.html"),
2019: path.resolve(__dirname, "src", "2019", "index.html"),
},
},
},
plugins: [etaPlugin()],
server: {
port: 3000,
hot: true,
},
});