-
Notifications
You must be signed in to change notification settings - Fork 19
/
vite.config.js
46 lines (42 loc) · 918 Bytes
/
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
import path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import svg from '@poppanator/sveltekit-svg';
import fs from 'fs';
const svgPluginOptions = {
svgoOptions: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false
}
}
},
'removeDimensions'
]
}
};
/** @type {import('vite').UserConfig} */
const config = {
resolve: {
alias: {
$icons: path.resolve('./src/icons'),
$utils: path.resolve('./src/utils')
}
},
plugins: [sveltekit(), svg(svgPluginOptions), rawFonts(['.ttf'])],
legacy: { buildSsrCjsExternalHeuristics: true }
};
function rawFonts(ext) {
return {
name: 'vite-plugin-raw-fonts',
transform(code, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
}
}
};
}
export default config;