49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
![]() |
function defineConfig(config) {
|
||
|
return config;
|
||
|
}
|
||
|
function getViteConfig(inlineConfig) {
|
||
|
return async ({ mode, command }) => {
|
||
|
const cmd = command === "serve" ? "dev" : command;
|
||
|
const [
|
||
|
fs,
|
||
|
{ mergeConfig },
|
||
|
{ nodeLogDestination },
|
||
|
{ openConfig, createSettings },
|
||
|
{ createVite },
|
||
|
{ runHookConfigSetup, runHookConfigDone },
|
||
|
{ astroContentListenPlugin }
|
||
|
] = await Promise.all([
|
||
|
import("node:fs"),
|
||
|
import("vite"),
|
||
|
import("../core/logger/node.js"),
|
||
|
import("../core/config/index.js"),
|
||
|
import("../core/create-vite.js"),
|
||
|
import("../integrations/index.js"),
|
||
|
import("./vite-plugin-content-listen.js")
|
||
|
]);
|
||
|
const logging = {
|
||
|
dest: nodeLogDestination,
|
||
|
level: "info"
|
||
|
};
|
||
|
const { astroConfig: config } = await openConfig({ cmd });
|
||
|
const settings = createSettings(config, inlineConfig.root);
|
||
|
await runHookConfigSetup({ settings, command: cmd, logging });
|
||
|
const viteConfig = await createVite(
|
||
|
{
|
||
|
mode,
|
||
|
plugins: [
|
||
|
// Initialize the content listener
|
||
|
astroContentListenPlugin({ settings, logging, fs })
|
||
|
]
|
||
|
},
|
||
|
{ settings, logging, mode }
|
||
|
);
|
||
|
await runHookConfigDone({ settings, logging });
|
||
|
return mergeConfig(viteConfig, inlineConfig);
|
||
|
};
|
||
|
}
|
||
|
export {
|
||
|
defineConfig,
|
||
|
getViteConfig
|
||
|
};
|