0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00
astro/packages/create-astro/src/config.ts

22 lines
681 B
TypeScript
Raw Normal View History

export const createConfig = ({ integrations }: { integrations: string[] }) => {
if (integrations.length === 0) {
return `import { defineConfig } from 'astro/config';
// https://astro.build/config
export default defineConfig({});
`;
}
const rendererImports = integrations.map((r: string) => ` import ${r} from '@astrojs/${r === 'solid' ? 'solid-js' : r}';`);
const rendererIntegrations = integrations.map((r: string) => ` ${r}(),`);
2021-12-22 16:11:05 -05:00
return [
`import { defineConfig } from 'astro/config';`,
...rendererImports,
`// https://astro.build/config`,
`export default defineConfig({`,
` integrations: [`,
...rendererIntegrations,
` ]`,
`});`,
2021-12-22 16:11:05 -05:00
].join('\n');
2021-07-07 20:10:09 +00:00
};