-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
index.ts
40 lines (36 loc) · 1.01 KB
/
index.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
import type { Options } from '@sveltejs/vite-plugin-svelte';
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import type { AstroIntegration, AstroRenderer, ContainerRenderer } from 'astro';
function getRenderer(): AstroRenderer {
return {
name: '@astrojs/svelte',
clientEntrypoint: '@astrojs/svelte/client.js',
serverEntrypoint: '@astrojs/svelte/server.js',
};
}
export function getContainerRenderer(): ContainerRenderer {
return {
name: '@astrojs/svelte',
serverEntrypoint: '@astrojs/svelte/server.js',
};
}
export default function svelteIntegration(options?: Options): AstroIntegration {
return {
name: '@astrojs/svelte',
hooks: {
'astro:config:setup': async ({ updateConfig, addRenderer }) => {
addRenderer(getRenderer());
updateConfig({
vite: {
optimizeDeps: {
include: ['@astrojs/svelte/client.js'],
exclude: ['@astrojs/svelte/server.js'],
},
plugins: [svelte(options)],
},
});
},
},
};
}
export { vitePreprocess };