-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
40 lines (36 loc) · 809 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
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
const SVELTE_IMPORTS = [
'svelte/animate',
'svelte/easing',
'svelte/internal',
'svelte/motion',
'svelte/store',
'svelte/transition',
'svelte',
]
export default defineConfig({
plugins: [
svelte(),
// Optimize svelte imports to dedupe Svelte
patchSvelte(),
],
})
function patchSvelte() {
return {
name: 'svelte:patch',
config(cfg) {
// Remove svelte imports added by vite-plugin-svelte
if (cfg.optimizeDeps?.exclude) {
cfg.optimizeDeps.exclude = cfg.optimizeDeps.exclude.filter(
(dep) => !SVELTE_IMPORTS.includes(dep)
)
}
return {
optimizeDeps: {
include: [...SVELTE_IMPORTS],
},
}
},
}
}