diff --git a/.changeset/lovely-elephants-peel.md b/.changeset/lovely-elephants-peel.md new file mode 100644 index 0000000000..7dfe25b9cb --- /dev/null +++ b/.changeset/lovely-elephants-peel.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Remove redundant comments when `astro add` update `astro.config.mjs` diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index d90075ce78..3abe00db97 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -507,7 +507,7 @@ async function updateAstroConfig({ let output = await generate(ast); const comment = '// https://astro.build/config'; const defaultExport = 'export default defineConfig'; - output = output.replace(` ${comment}`, ''); + output = output.replace(`\n${comment}`, ''); output = output.replace(`${defaultExport}`, `\n${comment}\n${defaultExport}`); if (input === output) {