[astro add] Set output: 'server'
when adding adapter (#4289)
* fix: add `output: 'server'` when setting adapter * chore: changeset
This commit is contained in:
parent
62763d50b5
commit
3ca9051749
2 changed files with 22 additions and 0 deletions
5
.changeset/witty-bears-joke.md
Normal file
5
.changeset/witty-bears-joke.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
[astro add] Set `output: 'server'` when adding adapter
|
|
@ -396,6 +396,23 @@ async function setAdapter(ast: t.File, adapter: IntegrationInfo, exportName: str
|
||||||
const configObject = path.node.declaration.arguments[0];
|
const configObject = path.node.declaration.arguments[0];
|
||||||
if (!t.isObjectExpression(configObject)) return;
|
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) => {
|
let adapterProp = configObject.properties.find((prop) => {
|
||||||
if (prop.type !== 'ObjectProperty') return false;
|
if (prop.type !== 'ObjectProperty') return false;
|
||||||
if (prop.key.type === 'Identifier') {
|
if (prop.key.type === 'Identifier') {
|
||||||
|
|
Loading…
Reference in a new issue