-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
66 lines (62 loc) · 2.1 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 { sveltekit } from '@sveltejs/kit/vite';
import { plugin as md, Mode } from 'vite-plugin-markdown';
import hljs from 'highlight.js';
import hljs_svelte from 'highlightjs-svelte';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(
fileURLToPath(
import.meta.url)
); // jshint ignore:line
hljs_svelte(hljs)
const mdPlugin = md({
mode: Mode.HTML,
markdownIt: {
typographer: true,
highlight: function(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(str, { language: lang }).value
} catch {
console.log(`error highlighting for ${lang}`)
}
}
return '' // use external default escaping
},
},
})
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit(), mdPlugin],
server: {
fs: {
// throws an error without this when importing Fira font
allow: ['..']
},
proxy: {},
port: 5174,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,OPTIONS,PATCH,DELETE,POST,PUT',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
}
},
resolve: {
alias: {
$actions: resolve(__dirname, './src/lib/actions'),
$components: resolve(__dirname, './src/lib/components'),
$section: resolve(__dirname, './src/lib/components/section'),
$shared: resolve(__dirname, './src/lib/components/shared'),
$data: resolve(__dirname, './src/lib/data'),
$models: resolve(__dirname, './src/lib/models'),
$screens: resolve(__dirname, './src/lib/screens'),
$services: resolve(__dirname, './src/lib/services'),
$stores: resolve(__dirname, './src/lib/stores'),
$utils: resolve(__dirname, './src/lib/utils'),
},
},
define: {
'__SERVER_VERSION__': JSON.stringify(process.env.npm_package_version),
}
};
export default config;