React ssr exmaple with typescript, babel, css-modules, react-router, redux, redux-thunk, ramda, webpack 4.
You can read more about the organizational strategy used in this app in this Medium post, or this post.
- React 16.8
- React Router 5.0
- Redux 4
- Redux-Thunk 2.3
- react-hot-loader 4.11
- Ramda 0.26
- express 4.17
- babel 7
- webpack 4.33
- webpack-dev-middleware 3.7
- webpack-hot-middleware 2.25
@client/*resolves to./src/client/*@server/*resolves to./src/server/*@core/*resolves to./src/core/*
Routes in project are objects with the same properties as a <Route> with a couple differences:
- the only render prop it accepts is
component(norenderorchildren) - introduces the
routeskey for sub routes - introduces the
preloadActionskey for preFetch on server - Consumers are free to add any additional props they'd like to a route, you can access
props.routeinside thecomponent, this object is a reference to the object used to render and match. - accepts
keyprop to prevent remounting component when transition was made from route with the same component and samekeyprop
const routes = [
{
component: Root,
preloadActions: someAction('someProp'), // preloadActions: {type: 'someAction', payload: someProps}
routes: [
{
path: '/',
exact: true,
component: Home,
preloadActions: [someAction('someProp'), someSecondAction('someProps')]
},
{
path: '/child/:id',
component: Child,
routes: [
{
path: '/child/:id/grand-child',
component: GrandChild
}
]
}
]
}
];Note: Just like <Route>, relative paths are not (yet) supported. When it is supported there, it will be supported
here.
It uses the usual SCSS css modules. You can find more information here
To be able to reload the page and see the latest code changes, you must set the "localStorage.useRender" value in development mode (the hydrate method will be replaced with the render)
$ npm installStart express development server
$ npm run startBuild client for production
$ npm run build:clientBuild server for production
$ npm run build:serverOr simply
$ npm run buildBuild server and client for production
Vendors Size (all node_modules)
$ npm run analyze:vendorsBundle Size (all exclude node_modules)
$ npm run analyze:bundleOr simply
$ npm run analyzeTo see the size and bundle and vendors