diff --git a/README.md b/README.md index c5df8fa2..b424a8d8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Any framework that can generate a build output in accordance with the App Hostin 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. > [!NOTE] -> App Hosting technically supports all all node applications, but no custom framework features will be enabled without the output bundle. +> App Hosting technically supports all node applications, but no custom framework features will be enabled without the output bundle. ## Output bundle Schema @@ -37,6 +37,7 @@ interface OutputBundle { version: "v1" runConfig: RunConfig; metadata: Metadata; + outputFiles?: OutputFiles; } ``` @@ -108,12 +109,44 @@ interface Metadata { | `framework` | `string` | Name of the framework that is being supported | y | | `frameworkVersion` | `string` |Version of the framework that is being supported | n | +### OutputFiles + +OutputFiles is an optional field to configure outputFiles and optimize server files + static assets. + +```typescript +interface OutputFiles { + serverApp: ServerApp +} + +``` + +| Field | Type | Description | Required? | +| ---------- | ------- | - | - | +| `serverApp` | `ServerApp` | ServerApp holds configurations related to the serving files at runtime from Cloud Run | y | + +### ServerApp + +OutputFiles is an optional field to configure outputFiles and optimize server files + static assets. + +```typescript +interface ServerApp { + include: string[] +} + +``` + +| Field | Type | Description | Required? | +| ---------- | ------- | - | - | +| `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 | + +## Sample + Here is a sample `.apphosting/bundle.yaml` file putting all this together: ```yaml version: v1 runConfig: - runCommand: 'node dist/index.js' + runCommand: node dist/index.js environmentVariables: - variable: VAR value: 8080 @@ -123,6 +156,12 @@ runConfig: memoryMiB: 512 minInstances: 0 maxInstances: 14 + +outputFiles: + serverApp: + include: + - dist + - .output metadata: adapterPackageName: npm-name diff --git a/packages/@apphosting/adapter-nextjs/src/overrides.ts b/packages/@apphosting/adapter-nextjs/src/overrides.ts index d680e319..48982951 100644 --- a/packages/@apphosting/adapter-nextjs/src/overrides.ts +++ b/packages/@apphosting/adapter-nextjs/src/overrides.ts @@ -72,10 +72,9 @@ export async function overrideNextConfig(projectRoot: string, nextConfigFileName * Current overrides include: * - images.unoptimized = true, unless user explicitly sets images.unoptimized to false or * is using a custom image loader. - * * @param importStatement The import statement for the original config. * @param fileExtension The file extension of the original config. Use ".js", ".mjs", or ".ts" - * @returns The custom Next.js config. + * @return The custom Next.js config. */ function getCustomNextConfig(importStatement: string, fileExtension: string) { return ` @@ -150,7 +149,6 @@ export async function validateNextConfigOverride( * This function adds the following headers to all routes: * - x-fah-adapter: The Firebase App Hosting adapter version used to build the app. * - x-fah-middleware: When middleware is enabled. - * * @param appPath The path to the app directory. * @param distDir The path to the dist directory. * @param adapterMetadata The adapter metadata. diff --git a/packages/@apphosting/adapter-nextjs/src/utils.ts b/packages/@apphosting/adapter-nextjs/src/utils.ts index be706599..bc50afd3 100644 --- a/packages/@apphosting/adapter-nextjs/src/utils.ts +++ b/packages/@apphosting/adapter-nextjs/src/utils.ts @@ -42,7 +42,7 @@ export async function loadConfig(root: string, projectRoot: string): Promise