Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function generateIndex(
baseOutputPath: string,
options: BrowserBuilderOptions,
root: string,
files: EmittedFiles[] | undefined,
noModuleFiles: EmittedFiles[] | undefined,
moduleFiles: EmittedFiles[] | undefined,
transformer?: IndexHtmlTransform,
locale?: string,
baseHref?: string,
): Promise {
const host = new NodeJsSyncHost();
return writeIndexHtml({
host,
outputPath: join(normalize(baseOutputPath), getIndexOutputFile(options)),
indexPath: join(normalize(root), getIndexInputFile(options)),
files,
noModuleFiles,
moduleFiles,
baseHref,
deployUrl: options.deployUrl,
sri: options.subresourceIntegrity,
scripts: options.scripts,
styles: options.styles,
postTransform: transformer,
crossOrigin: options.crossOrigin,
lang: locale,
}).toPromise();
}
async (stats: webpack.Stats) => {
if (!stats.hasErrors() && this.browserIndexSourcePath && this.browserIndexOutputPath) {
const root = normalize(this.builderContext.workspaceRoot);
const builderOutput = createUniversalBuilderOutput(
this.builderOptions as json.JsonObject & BuildUdkSchema,
this.browserOptions as json.JsonObject & BrowserBuilderSchema,
this.serverOptions as json.JsonObject & ServerBuilderSchema,
stats,
this.webpackConfig as webpack.Configuration[],
);
await writeIndexHtml({
host: this.host,
outputPath: resolve(
root, join(normalize(this.browserOptions.outputPath),
getIndexOutputFile(this.browserOptions)),
),
indexPath: join(root, getIndexInputFile(this.browserOptions)),
files: builderOutput.browserFiles,
noModuleFiles: builderOutput.browserNoModuleFiles,
moduleFiles: builderOutput.browserModuleFiles,
baseHref: this.browserOptions.baseHref,
deployUrl: this.browserOptions.deployUrl,
sri: this.browserOptions.subresourceIntegrity,
scripts: this.browserOptions.scripts,
styles: this.browserOptions.styles,
}).toPromise();
}
},
);