summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/witty-bears-joke.md5
-rw-r--r--packages/astro/src/core/add/index.ts17
2 files changed, 22 insertions, 0 deletions
diff --git a/.changeset/witty-bears-joke.md b/.changeset/witty-bears-joke.md
new file mode 100644
index 000000000..65b04583d
--- /dev/null
+++ b/.changeset/witty-bears-joke.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+[astro add] Set `output: 'server'` when adding adapter
diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts
index a9152654e..280c16db3 100644
--- a/packages/astro/src/core/add/index.ts
+++ b/packages/astro/src/core/add/index.ts
@@ -396,6 +396,23 @@ async function setAdapter(ast: t.File, adapter: IntegrationInfo, exportName: str
const configObject = path.node.declaration.arguments[0];
if (!t.isObjectExpression(configObject)) return;
+ let outputProp = configObject.properties.find((prop) => {
+ if (prop.type !== 'ObjectProperty') return false;
+ if (prop.key.type === 'Identifier') {
+ if (prop.key.name === 'output') return true;
+ }
+ if (prop.key.type === 'StringLiteral') {
+ if (prop.key.value === 'output') return true;
+ }
+ return false;
+ }) as t.ObjectProperty | undefined;
+
+ if (!outputProp) {
+ configObject.properties.push(
+ t.objectProperty(t.identifier('output'), t.stringLiteral('server'))
+ );
+ }
+
let adapterProp = configObject.properties.find((prop) => {
if (prop.type !== 'ObjectProperty') return false;
if (prop.key.type === 'Identifier') {