-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.mjs
43 lines (41 loc) · 1.15 KB
/
config.mjs
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
export function defineConfig(config) {
return config;
}
export function getViteConfig(inlineConfig) {
// Return an async Vite config getter which exposes a resolved `mode` and `command`
return async ({ mode, command }) => {
// Vite `command` is `serve | build`, but Astro uses `dev | build`
const cmd = command === 'serve' ? 'dev' : command;
// Use dynamic import to avoid pulling in deps unless used
const [
{ mergeConfig },
{ nodeLogDestination },
{ openConfig },
{ createVite },
{ runHookConfigSetup, runHookConfigDone },
] = await Promise.all([
import('vite'),
import('./dist/core/logger/node.js'),
import('./dist/core/config.js'),
import('./dist/core/create-vite.js'),
import('./dist/integrations/index.js'),
]);
const logging = {
dest: nodeLogDestination,
level: 'info',
};
const { astroConfig: config } = await openConfig({
cmd,
logging,
});
await runHookConfigSetup({ config, command: cmd });
const viteConfig = await createVite(
{
mode,
},
{ astroConfig: config, logging: logging, mode }
);
await runHookConfigDone({ config });
return mergeConfig(viteConfig, inlineConfig);
};
}