-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.js
56 lines (54 loc) · 1.37 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
import { sveltekit } from '@sveltejs/kit/vite';
import svg from '@poppanator/sveltekit-svg';
import { defineConfig } from 'vite';
import BuildManifest from './tools/BuildManifest.js';
export default defineConfig({
plugins: [
sveltekit(),
svg({
includePaths: ['./src/lib/icons/', './src/lib/images'],
svgoOptions: {
multipass: true,
plugins: [
{
name: 'preset-default',
// by default svgo removes the viewBox which prevents svg icons from scaling
// not a good idea! https://github.com/svg/svgo/pull/1461
params: { overrides: { removeViewBox: false } }
},
{
name: 'convertColors',
params: {
currentColor: true
}
},
{ name: 'removeAttrs', params: { attrs: '(width|height)' } }
]
}
}),
BuildManifest({
manifest: {
name: 'Kinegram'
}
})
],
css: {
preprocessorOptions: {
hoistUseStatements: true,
scss: {
additionalData: (content) => {
const imports = `@import "$lib/styles/common.scss";`;
// If there are @use statements, insert the import after the last one,
// otherwise insert it before all content.
const match = content.match(/@use '[^']+';/g);
if (match) {
const last = match[match.length - 1];
return content.replace(last, `${last}\n${imports}`);
} else {
return `${imports}\n${content}`;
}
}
}
}
}
});