Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions goldens/public-api/angular/build/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type ApplicationBuilderOptions = {
poll?: number;
polyfills?: string[];
prerender?: PrerenderUnion;
prerenderFormat?: PrerenderFormat;
preserveSymlinks?: boolean;
progress?: boolean;
scripts?: ScriptElement[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function executePostBundleSteps(
outputMode,
serverEntryPoint,
prerenderOptions,
prerenderFormat,
appShellOptions,
publicPath,
workspaceRoot,
Expand Down Expand Up @@ -168,6 +169,8 @@ export async function executePostBundleSteps(
[...outputFiles, ...additionalOutputFiles],
assetFiles,
outputMode,
prerenderFormat,
indexHtmlOptions.output,
sourcemapOptions.scripts,
maxWorkers,
);
Expand Down
16 changes: 16 additions & 0 deletions packages/angular/build/src/builders/application/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
OutputMode,
OutputPathClass,
Platform,
PrerenderFormat,
} from './schema';

/**
Expand Down Expand Up @@ -342,6 +343,20 @@ export async function normalizeOptions(
options.outputMode === OutputMode.Static,
};

let prerenderFormat = options.prerenderFormat ?? PrerenderFormat.Directory;
if (prerenderFormat === PrerenderFormat.File && !outputOptions.ignoreServer) {
// The server runtime of '@angular/ssr' looks up prerendered pages as '<route>/index.html'.
// The warning is only relevant when pages are actually prerendered, which the dev-server skips.
if ((prerenderOptions || appShellOptions) && !(options.partialSSRBuild || usePartialSsrBuild)) {
context.logger.warn(
'The "prerenderFormat" option set to "file" is not considered when the build produces a ' +
'server ("outputMode" set to "server", or "ssr" without "outputMode").',
);
}

prerenderFormat = PrerenderFormat.Directory;
}

const outputNames = {
bundles:
options.outputHashing === OutputHashing.All || options.outputHashing === OutputHashing.Bundles
Expand Down Expand Up @@ -492,6 +507,7 @@ export async function normalizeOptions(
subresourceIntegrity,
serverEntryPoint,
prerenderOptions,
prerenderFormat,
appShellOptions,
outputMode,
ssrOptions,
Expand Down
6 changes: 6 additions & 0 deletions packages/angular/build/src/builders/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@
}
]
},
"prerenderFormat": {
"type": "string",
"description": "Defines the file layout of prerendered (SSG) pages. 'directory': '/foo' is written to 'foo/index.html'. 'file': '/foo' is written to 'foo.html', which some hosting services serve for '/foo' without a redirect to '/foo/'. The root route of the application and of each locale is always written to 'index.html'. Routes that cannot be written safely to '<route>.html' keep '<route>/index.html' with a warning. Only considered when the build does not produce a server.",
"enum": ["directory", "file"],
"default": "directory"
},
"ssr": {
"description": "Server side render (SSR) pages of your application during runtime.",
"default": false,
Expand Down
Loading
Loading