Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(server): resolve assets and faviconsAssets async using getStats()
Browse files Browse the repository at this point in the history
feat(server): resolve assets and faviconsAssets async using `getStats()`
  • Loading branch information
Metnew committed Nov 6, 2017
1 parent 0b56c4f commit ca8ae99
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/server/ssr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ import {configureRootComponent, configureApp} from 'common/app'
import asyncBootstrapper from 'react-async-bootstrapper'
import {AsyncComponentProvider, createAsyncContext} from 'react-async-component'
import HTMLComponent from './HTMLComponent'
// $FlowFixMe
import assets from 'webpack-assets'
// $FlowFixMe
import faviconsAssets from 'favicons-assets'
import getI18nData from 'server/i18n'
import {matchPath} from 'react-router'
import getStats from './stats'

// it's better to define these objs in global scope (less memory consumption)
let {assets, faviconsAssets} = {}
getStats().then(result => {
assets = result.assets
faviconsAssets = result.faviconsAssets
})

export default async (req: express$Request, res: express$Response) => {
const {isLoggedIn, language} = req.user
Expand Down

0 comments on commit ca8ae99

Please sign in to comment.