import React from 'react' import express from 'express' import ReactDOMServer from 'react-dom/server' import { renderToString } from 'glamor-jss' import CleanCss from 'clean-css' import App from './App' const assets = require(process.env.RAZZLE_ASSETS_MANIFEST) // You can minify the CSS sent from the server to save some bytes const clean = new CleanCss() const server = express() server .disable('x-powered-by') .use(express.static(process.env.RAZZLE_PUBLIC_DIR)) .get('/*', (req, res) => { const html = ReactDOMServer.renderToString() const css = renderToString() const { styles } = clean.minify(css) res.status(200).send( ` glamor-jss ${ process.env.NODE_ENV === 'production' ? `` : `` }
${html}
` ) }) export default server