-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvite.config.ts
75 lines (72 loc) · 1.84 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
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { sveltekit } from '@sveltejs/kit/vite';
import babel from 'vite-plugin-babel';
import { defineConfig } from 'vitest/config';
import { plugin as mdPlugin, Mode } from 'vite-plugin-markdown';
import markdownIt from 'markdown-it';
import markdownItAnchor from 'markdown-it-anchor';
// @ts-expect-error
import markdownItCheckbox from 'markdown-it-checkbox';
export default defineConfig({
plugins: [
// @ts-expect-error
sveltekit(),
// @ts-expect-error
babel({
filter: /\.(mdx|jsx|tsx)$/,
babelConfig: {
presets: ['@babel/preset-react']
}
}),
// @ts-expect-error
mdPlugin({
mode: [Mode.HTML],
markdown: (body: string) => {
const md = markdownIt({
html: true,
linkify: true,
typographer: true
})
.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.ariaHidden({
symbol: '§',
space: true,
placement: 'after'
}),
slugify: (text: string) =>
text
.replaceAll(/'"’/g, '')
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
.replaceAll(/[^a-z0-9-_]+/g, '-')
.replace(/(^-+)|(-+$)/, '')
})
.use(markdownItCheckbox);
md.core.ruler.before('inline', 'french-typo', function replace(state) {
const tokens = state.tokens;
for (let i = 2; i < tokens.length; i++) {
const token = tokens[i];
if (token.type === 'inline') {
token.content = token.content
.replaceAll(/ ([?!;])/g, ' $1')
.replaceAll(/ :/g, ' :');
}
}
});
return md.render(body);
}
})
],
test: {
server: {
deps: { inline: ['@sveltejs/kit'] }
},
include: ['src/**/*.{test,spec}.{js,ts}'],
environment: 'jsdom',
setupFiles: ['./tests/setup.ts']
},
server: {
host: '0.0.0.0'
}
});