Generates a static generated site (SSG)
function generateStatic(options: GenerateStaticOptions): Promise<{
files: any[];
elapsed: number;
}>;
options
site generation optionsOptions for generating static sites
type GenerateStaticOptions = {
entryFile?: string[];
entryMain?: string[];
entryHtml?: string[];
entryUrls?: string[];
ext?: string;
pretty?: boolean;
outDir?: string;
baseUrl?: string;
verbose?: boolean;
cssUrl?: string;
};
The base URL used to qualify in-page URLs to an external full URL
baseUrl?: string;
Name of the CSS styles file
cssUrl?: string;
The entry .js file (as an array, first found used)
entryFile?: string[];
The HTML file to use as template for generated files (as an array, first found used)
entryHtml?: string[];
The name of the entry point function in the entryFile (as an array, first found used)
entryMain?: string[];
The URL's to render (will also recursively render all linked URLs)
entryUrls?: string[];
The extension to append to all generated files (including the period)
ext?: string;
The output directory to write generated files
outDir?: string;
Prettify the generated HTML
pretty?: boolean;
Verbose output
verbose?: boolean;
The results of an SSRWorker/SSRWorkerThread render operation.
In addition to the content
property, this object includes
any properties from the ssr
property of the route object to
which the URL was matched. This can be used to return additional
information such as HTTP status codes from the rendering process.
type SSRResult = {
content: string;
};
The rendered HTML
content: string;
Implements page rendering for SSG and/or SSR
class SSRWorker {
init(options: {
entryFile: string;
entryMain: string;
entryHtml: string;
cssUrl?: string;
}): Promise<void>;
stop(): Promise<void>;
getStyles(): Promise<string>;
render(url: string, options: any): SSRResult;
}
Gets the declared CSS styles
getStyles(): Promise<string>;
Initializes the SSR worker
init(options: {
entryFile: string;
entryMain: string;
entryHtml: string;
cssUrl?: string;
}): Promise<void>;
options
Options
options.entryFile
The main entry .js file
options.entryMain
The name of the main function in the entry file
options.entryHtml
An HTML string into which mounted components will be written
options.cssUrl
A URL to use in-place of directly inserting CSS declarations
Renders a page
render(url: string, options: any): SSRResult;
url
URL of the page to render
options
Additional options to be made available via coenv
Stops the worker.
stop(): Promise<void>;
Runs an SSRWorker in a Node worker thread for application isolation
class SSRWorkerThread {
init(options: {
entryFile: string;
entryMain: string;
entryHtml: string;
cssUrl?: string;
}): Promise<void>;
render(url: string): SSRResult;
getStyles(): Promise<string>;
stop(): Promise<any>;
}
Gets the declared CSS styles
getStyles(): Promise<string>;
Initializes the SSR worker
init(options: {
entryFile: string;
entryMain: string;
entryHtml: string;
cssUrl?: string;
}): Promise<void>;
options
Options
options.entryFile
The main entry .js file
options.entryMain
The name of the main function in the entry file
options.entryHtml
An HTML string into which mounted components will be written
options.cssUrl
A URL to use in-place of directly inserting CSS declarations
Renders a page
render(url: string): SSRResult;
url
URL of the page to renderStops the worker.
stop(): Promise<any>;
Vite Plugin to generate static sites.
function viteGenerateStatic(options: GenerateStaticOptions): {
name: string;
configResolved: (config: any) => void;
buildStart: () => Promise<void>;
closeBundle: () => Promise<void>;
};
options
options used for static page generation