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 characters
| { | |
| "scripts": { | |
| "static": "cross-env RAZZLE_STATIC=true razzle build && cross-env NODE_ENV=production node build/server.js" | |
| } | |
| } |
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 characters
| import http from 'http' | |
| import fs from 'fs-extra' | |
| const staticDirectory = process.env.RAZZLE_STATIC_PATH || 'static' | |
| http.get({url: 'http://' + process.env.HOST + ':' + process.env.PORT | |
| , headers: {'User-Agent': 'all'} | |
| }, response => | |
| response.on('data', html => | |
| fs.writeFile(staticDirectory + '/' + 'index.html', html) |
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 characters
| class Main extends Component { | |
| constructor(properties) { | |
| super(properties) | |
| this.muiTheme = getMuiTheme({ | |
| userAgent: properties.userAgent | |
| }) | |
| } | |
| render = () => |
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 characters
| hydrate(<Application userAgent={navigator.userAgent} />, document.getElementById('root')) |
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 characters
| renderToString(<Application userAgent={request.headers['user-agent']} />) |
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 characters
| { | |
| "scripts": { | |
| "start": "razzle build && cross-env NODE_ENV=production node build/server.js" | |
| } | |
| } |
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 characters
| import {hydrate} from 'react-dom' | |
| import Application from './application/Main' | |
| hydrate(<Application />, document.getElementById('root')) |
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 characters
| import express from 'express' | |
| import server from './server' | |
| export default express() | |
| .use((request, response) => server.handle(request, response)) | |
| .listen(process.env.PORT) |
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 characters
| import {minify} from 'html-minifier' | |
| minify( | |
| `<!DOCTYPE HTML><html lang="en">...</html>` | |
| , { | |
| collapseWhitespace: true | |
| , removeComments: true | |
| , minifyCSS: true | |
| , minifyJS: true | |
| }) |
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 characters
| import {renderToString} from 'react-dom/server' | |
| import {ServerStyleSheet} from 'styled-components' | |
| import Application from './application/Main' | |
| const sheet = new ServerStyleSheet() | |
| , html = renderToString(sheet.collectStyles(<Application />)) | |
| , css = sheet.getStyleTags() | |
| // server response to send: |
NewerOlder