Skip to content

Commit 121558a

Browse files
authored
Update outputBundleConfig to include outputfiles (#318)
* update output files * lint
1 parent 35f147e commit 121558a

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Any framework that can generate a build output in accordance with the App Hostin
1818
The output bundle primarily consists of a `bundle.yaml` file that sits inside of the `.apphosting` directory. This bundle.yaml contains all the ways that frameworks can configure App Hosting when users deploy their applications.
1919

2020
> [!NOTE]
21-
> App Hosting technically supports all all node applications, but no custom framework features will be enabled without the output bundle.
21+
> App Hosting technically supports all node applications, but no custom framework features will be enabled without the output bundle.
2222
2323
## Output bundle Schema
2424

@@ -37,6 +37,7 @@ interface OutputBundle {
3737
version: "v1"
3838
runConfig: RunConfig;
3939
metadata: Metadata;
40+
outputFiles?: OutputFiles;
4041
}
4142
```
4243

@@ -108,12 +109,44 @@ interface Metadata {
108109
| `framework` | `string` | Name of the framework that is being supported | y |
109110
| `frameworkVersion` | `string` |Version of the framework that is being supported | n |
110111

112+
### OutputFiles
113+
114+
OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.
115+
116+
```typescript
117+
interface OutputFiles {
118+
serverApp: ServerApp
119+
}
120+
121+
```
122+
123+
| Field | Type | Description | Required? |
124+
| ---------- | ------- | - | - |
125+
| `serverApp` | `ServerApp` | ServerApp holds configurations related to the serving files at runtime from Cloud Run | y |
126+
127+
### ServerApp
128+
129+
OutputFiles is an optional field to configure outputFiles and optimize server files + static assets.
130+
131+
```typescript
132+
interface ServerApp {
133+
include: string[]
134+
}
135+
136+
```
137+
138+
| Field | Type | Description | Required? |
139+
| ---------- | ------- | - | - |
140+
| `include` | `string[]` | include holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server, generally this will be the output/dist directory (e.g. .output or dist). In the case that the framework wants to include all files they can use [“.”] | y |
141+
142+
## Sample
143+
111144
Here is a sample `.apphosting/bundle.yaml` file putting all this together:
112145

113146
```yaml
114147
version: v1
115148
runConfig:
116-
runCommand: 'node dist/index.js'
149+
runCommand: node dist/index.js
117150
environmentVariables:
118151
- variable: VAR
119152
value: 8080
@@ -123,6 +156,12 @@ runConfig:
123156
memoryMiB: 512
124157
minInstances: 0
125158
maxInstances: 14
159+
160+
outputFiles:
161+
serverApp:
162+
include:
163+
- dist
164+
- .output
126165

127166
metadata:
128167
adapterPackageName: npm-name

packages/@apphosting/adapter-nextjs/src/overrides.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ export async function overrideNextConfig(projectRoot: string, nextConfigFileName
7272
* Current overrides include:
7373
* - images.unoptimized = true, unless user explicitly sets images.unoptimized to false or
7474
* is using a custom image loader.
75-
*
7675
* @param importStatement The import statement for the original config.
7776
* @param fileExtension The file extension of the original config. Use ".js", ".mjs", or ".ts"
78-
* @returns The custom Next.js config.
77+
* @return The custom Next.js config.
7978
*/
8079
function getCustomNextConfig(importStatement: string, fileExtension: string) {
8180
return `
@@ -150,7 +149,6 @@ export async function validateNextConfigOverride(
150149
* This function adds the following headers to all routes:
151150
* - x-fah-adapter: The Firebase App Hosting adapter version used to build the app.
152151
* - x-fah-middleware: When middleware is enabled.
153-
*
154152
* @param appPath The path to the app directory.
155153
* @param distDir The path to the dist directory.
156154
* @param adapterMetadata The adapter metadata.

packages/@apphosting/adapter-nextjs/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function loadConfig(root: string, projectRoot: string): Promise<Nex
4242
* Loads the route manifest from the standalone directory.
4343
* @param standalonePath The path to the standalone directory.
4444
* @param distDir The path to the dist directory.
45-
* @returns The route manifest.
45+
* @return The route manifest.
4646
*/
4747
export function loadRouteManifest(standalonePath: string, distDir: string): RoutesManifest {
4848
const manifestPath = join(standalonePath, distDir, ROUTES_MANIFEST);
@@ -54,7 +54,7 @@ export function loadRouteManifest(standalonePath: string, distDir: string): Rout
5454
* Loads the middleware manifest from the standalone directory.
5555
* @param standalonePath The path to the standalone directory.
5656
* @param distDir The path to the dist directory.
57-
* @returns The middleware manifest.
57+
* @return The middleware manifest.
5858
*/
5959
export function loadMiddlewareManifest(
6060
standalonePath: string,

packages/@apphosting/common/src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface OutputBundleConfig {
55
version: "v1";
66
runConfig: RunConfig;
77
metadata: Metadata;
8+
outputFiles?: OutputFiles;
89
}
910

1011
// Fields needed to configure the App Hosting server
@@ -38,6 +39,18 @@ export interface Metadata {
3839
frameworkVersion?: string;
3940
}
4041

42+
// Optional outputFiles to configure outputFiles and optimize server files + static assets.
43+
// If this is not set then all of the source code will be uploaded
44+
interface OutputFiles {
45+
serverApp: ServerApp;
46+
}
47+
48+
// ServerApp holds a list of directories + files relative to the app root dir that frameworks need to deploy to the App Hosting server,
49+
// generally this will be the output/dist directory (e.g. .output or dist). To include all files set this to [“.”]
50+
interface ServerApp {
51+
include: string[];
52+
}
53+
4154
// Represents a single environment variable.
4255
export interface EnvVarConfig {
4356
// Name of the variable

0 commit comments

Comments
 (0)