import * as fs from 'fs'; import { resolve as pathResolve } from 'path'; import { getBuildPath } from '@erect/core/paths'; import { config } from '@erect/core/config'; import { renderHtmlPage } from '@erect/server/middlewares/app/htmlPage'; import { createLocation } from '@erect/core/shared/Location'; import { bundleAssetBase } from '@erect/core/shared/uri'; export function createServerlessHtmlPage() { return new Promise((resolve, reject) => { const htmlPageFile = pathResolve(getBuildPath(), config.bundles.client.buildOutputDir, 'index.html'); const htmlPage = renderHtmlPage({ nonce: '%NONCE%', location: createLocation(bundleAssetBase('index.html')), }); fs.writeFile(htmlPageFile, htmlPage, 'utf8', (error) => { if (error) { reject(error); return; } resolve(); }); }); }