Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
packages: activatedPackages,
}),
);
store.dispatch(settingsModule.actions.settingsUpdated({ settings }));
// Run and wait until all the server sagas have run.
const startSagas = new Date();
const sagaPromises = Object.values(serverSagas).map(saga => store.runSaga(saga).done);
store.dispatch(buildModule.actions.serverSagasInitialized());
await Promise.all(sagaPromises);
store.dispatch(buildModule.actions.serverFinished({ timeToRunSagas: new Date() - startSagas }));
// Generate React SSR.
app = renderToString();
const { html, ids, css } = extractCritical(app);
// Get static helmet strings.
const helmet = Helmet.renderStatic();
// Flush chunk names and extract scripts, css and css<->scripts object.
const chunkNames = flushChunkNames();
const { cssHashRaw, scripts, stylesheets } = flushChunks(clientStats, { chunkNames });
const publicPath = req.query.static
? `${req.query.static.replace(/\/$/g, '')}/static/`
: '/static/';
const cssHash = JSON.stringify(mapValues(cssHashRaw, cssPath => `${publicPath}${cssPath}`));
const scriptsWithoutBootstrap = scripts.filter(script => !/bootstrap/.test(script));
const chunksForArray = scriptsWithoutBootstrap.map(script => `'${script}'`).join(',');
const bootstrapFileName = scripts.filter(script => /bootstrap/.test(script));
const bootstrapString = await readFile(
export const replaceRenderer = ({
bodyComponent,
replaceBodyHTMLString,
setHeadComponents,
}) => {
const { html, ids, css } = extractCritical(
renderToString(wrapElement(bodyComponent))
)
setHeadComponents([
// eslint-disable-next-line react/jsx-key
<style data-emotion-css="{ids.join(`">,
])
replaceBodyHTMLString(html)
}
</style>
static getInitialProps({ renderPage }) {
const page = renderPage()
const styles = extractCritical(page.html)
return { ...page, ...styles }
}
function templateForProduction (entrypoints, props, route) {
process.env.NODE_ENV = 'production'
const hijacked = hijackConsole()
const serverEntry = babelRequire('../../themes/server.js')
const app = serverEntry.default(props, route)
const rendered = extractCritical(renderToString(app))
hijacked.restore()
const helmet = Helmet.renderStatic()
const template = `
${helmet.title.toString()}
${helmet.base.toString()}
${helmet.meta.toString()}
${helmet.link.toString()}
${helmet.style.toString()}
${helmet.script.toString()}
<style type="text/css">${rendered.css}</style>
export const replaceRenderer = ({
bodyComponent,
replaceBodyHTMLString,
setHeadComponents,
}) => {
const ConnectedBody = () => <>{bodyComponent};
const { html, ids, css } = extractCritical(renderToString());
const criticalStyle =
static getInitialProps({renderPage}) {
const sheet = new ServerStyleSheet()
const page = renderPage(App => props => sheet.collectStyles())
return {
...page,
styles: (
<>
{sheet.getStyleElement()}
)
}
}
static getInitialProps({ renderPage }) {
const page = renderPage();
const styles = extractCritical(page.html);
return { ...page, ...styles };
}
const hydrateByEmotion = (html) => {
const { hydrate } = require('emotion');
const { extractCritical } = require('emotion-server');
const { ids } = extractCritical(html);
hydrate(ids);
};
static getInitialProps({ renderPage }) {
const page = renderPage();
const styles = extractCritical(page.html);
return { ...page, ...styles };
}
export const wrapRootElement = ({ element } /*, options*/) => {
const string = renderToString({element});
emotionSSR = extractCritical(string);
return {element};
};