This file contains 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 characters
entry: { | |
main: './client/index.js', | |
}, | |
output: { | |
path: path.resolve('./build/client'), | |
filename: 'js/[name].[chunkhash:8].js', | |
}, | |
module: { | |
rules: [ | |
{ test: /\.js$/, exclude: /node_modules/, use: ['babel-loader'] }, |
This file contains 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 characters
const serverRenderedHtml = async (req, res, renderProps) => { | |
const store = configureStore(); | |
//call, wait, and set api responses into redux store's state (ghub.io/redux-connect) | |
await loadOnServer({ ...renderProps, store }); | |
//render the html template | |
const template = html( | |
renderToString( | |
<Provider store={store} key="provider"> | |
<ReduxAsyncConnect {...renderProps} /> | |
</Provider>, |
This file contains 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 characters
<Route | |
name="landing" | |
path="/" | |
getComponent={ | |
(_, cb) => import('./views/LandingPage/LandingPage' /* webpackChunkName: 'landing' */) | |
.then((module) => cb(null, module.default)) | |
.catch((error) => cb(error, null)) | |
} | |
</Route> |
This file contains 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 characters
//add the webpackManifest and vendor script files to your html | |
<body> | |
<div id="root">${app}</div> | |
<script>window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}</script> | |
<script src="${assets.webpackManifest.js}"></script> | |
<script src="${assets.vendor.js}"></script> | |
<script src="${assets.main.js}"></script> | |
</body> |
This file contains 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 characters
earlyChunk(route) { | |
return ` | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="${assets.main.css}"> | |
<link rel="preload" as="script" href="${assets.webpackManifest.js}"> | |
<link rel="preload" as="script" href="${assets.vendor.js}"> | |
<link rel="preload" as="script" href="${assets.main.js}"> | |
${!assets[route.name] ? '' : `<link rel="preload" as="script" href="${assets[route.name].js}">`} |
This file contains 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 characters
resolve: { | |
alias: { | |
react: 'preact-compat', | |
'react-dom': 'preact-compat', | |
}, | |
}, |
This file contains 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 characters
{ | |
"name": "Treebo Hotels", | |
"short_name": "Treebo", | |
"description": "India's Top Rated Budget Hotel Chain", | |
"theme_color": "#ffffff", | |
"background_color": "#ffffff", | |
"start_url": "/", | |
"display": "standalone", | |
"orientation": "portrait", | |
"icons": [{ |
This file contains 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 characters
// register the service worker after the onload event to prevent | |
// bandwidth resource contention during the main and vendor js downloads | |
export const scripts = { | |
serviceWorker: | |
`"serviceWorker" in window.navigator && window.addEventListener("load", function() { | |
window.navigator.serviceWorker.register("/serviceWorker.js") | |
.then(function(r) { | |
console.log("ServiceWorker registration successful with scope: ", r.scope) | |
}).catch(function(e) { | |
console.error("ServiceWorker registration failed: ", e) |
This file contains 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 characters
import React, { PropTypes } from 'react'; | |
import cn from 'classnames'; | |
const Text = ({ | |
className, | |
tag, | |
preview, | |
previewStyle, | |
children, | |
...props |
This file contains 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 characters
import assetsManifest from '../../build/client/assetsManifest.json'; | |
lateChunk(app, head, initialState, route) { | |
return ` | |
<style>${assets.main.styles}</style> | |
// inline the current route's css and assign an id to it | |
${!assets[route.name] ? '' : `<style id="${route.name}.css">${assets[route.name].styles}</style>`} | |
</head> | |
<body> | |
<div id="root">${app}</div> |
OlderNewer