Skip to content

Instantly share code, notes, and snippets.

View cereallarceny's full-sized avatar
:shipit:

Patrick Cason cereallarceny

:shipit:
View GitHub Profile
@cereallarceny
cereallarceny / index.js
Last active May 2, 2023 06:41
Server-side rendering in Create React App
const md5File = require('md5-file');
const path = require('path');
// CSS styles will be imported on load and that complicates matters... ignore those bad boys!
const ignoreStyles = require('ignore-styles');
const register = ignoreStyles.default;
// We also want to ignore all image requests
// When running locally these will load from a standard import
// When running on the server, we want to load via their hashed version in the build folder
@cereallarceny
cereallarceny / index.js
Created October 12, 2017 20:37
Server-side rendering with create-react-app (Fiber), React Router v4, Helmet, Redux, and Thunk
// Ignore those pesky styles
require('ignore-styles');
// Set up babel to do its thing... env for the latest toys, react-app for CRA
require('babel-register')({
ignore: /\/(build|node_modules)\//,
presets: ['env', 'react-app']
});
// Now that the nonsense is over... load up the server entry point