Last active
February 22, 2019 12:36
-
-
Save adamhenson/40b90154d2cf4e55c081f92c8dfe8877 to your computer and use it in GitHub Desktop.
Revisions
-
adamhenson revised this gist
Feb 22, 2019 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,29 +5,32 @@ import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server'; import { Provider } from './somewhere/out/there/Provider'; import App from './somewhere/out/there/App'; const extractor = new ChunkExtractor({ statsFile: LOADABLE_STATS, }); export default (req, res) => { const html = renderToString( <Provider> <ChunkExtractorManager extractor={extractor} > <App /> </ChunkExtractorManager> </Provider>, ); return res.send(` <!doctype html> <html> <head> ${extractor.getStyleTags()} </head> <body> <div id="root"> ${html} </div> ${extractor.getScriptTags()} </body> </html> `); -
adamhenson created this gist
Feb 21, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ /* global LOADABLE_STATS: true */ import React from 'react'; import { renderToString } from 'react-dom/server'; import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server'; import { Provider } from './somewhere/out/there/Provider'; import App from './somewhere/out/there/App'; const extractor = new ChunkExtractor({ statsFile: LOADABLE_STATS }); export default (req, res) => { const html = renderToString( <Provider> <ChunkExtractorManager extractor={extractor}> <App /> </ChunkExtractorManager> </Provider>, ); const scriptTags = extractor.getScriptTags(); const styleTags = extractor.getStyleTags(); return res.send(` <!doctype html> <html> <head> ${styleTags} </head> <body> <div id="root">${html}</div> ${scriptTags} </body> </html> `); }