-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
88 lines (77 loc) · 2.29 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
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Vite 4 configuration file. See:
* https://kit.svelte.dev/docs/project-structure#project-files-vite-config-js
* https://vitejs.dev/config/
*/
import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';
import { type LogOptions, createLogger } from 'vite';
import Icons from 'unplugin-icons/vite';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import { sentrySvelteKit } from '@sentry/sveltekit';
import { enhancedImages } from '@sveltejs/enhanced-img';
import jsonServer from 'vite-plugin-simple-json-server';
const customLogger = (({ warnOnce, ...otherLogMethods }) => {
return {
...otherLogMethods,
// suppress missing sourcemap warnings from @aave/math-utils during unit tests
warnOnce(msg: string, options: LogOptions) {
if (/^Sourcemap for ".*@aave\/math-utils/.test(msg)) return;
warnOnce(msg, options);
}
};
})(createLogger());
export default defineConfig({
plugins: [
// Sentry plugin must be added befoer sveltekit plugin. See:
// https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/#vite-setup
sentrySvelteKit({
autoUploadSourceMaps: false
}),
enhancedImages(),
sveltekit(),
// see: https://github.com/unplugin/unplugin-icons
Icons({
compiler: 'svelte',
scale: 1,
customCollections: {
local: FileSystemIconLoader('./src/lib/assets/icons', (svg) => {
return svg.replace(
/^<svg /,
'<svg style="font-size: var(--icon-size, 1em); color: var(--icon-color, currentcolor);" '
);
})
},
iconCustomizer(_, icon, props) {
props.class = `icon ${icon}`;
}
}),
// vite plugin to create a mock JSON api for integration tests
// only available when using `npm run dev` or `npm run preview`
// https://github.com/alextim/vite-plugin-simple-json-server/
jsonServer({
logLevel: 'silent',
mockDir: 'tests/fixtures'
})
],
server: {
fs: {
allow: [process.cwd()]
}
},
customLogger,
build: {
// suppress chunk size warning during build
chunkSizeWarningLimit: 600,
sourcemap: true
},
// vitest configuration for unit tests (`npm run test:unit`)
// https://vitest.dev/config/
test: {
environment: 'jsdom',
globals: true,
include: ['src/**/*.{test,spec}.{js,ts}'],
restoreMocks: true,
setupFiles: ['tests/vitest.config.ts']
}
});