- React
- Redux
- MongoDB
- Node.JS
- Webpack2
- FlowTypes
- Styled-Component
- Service-Worker
- App Caching
The test link https://googlechrome.github.io/lighthouse/viewer/?gist=66a00c9974e7b3bb4ba1fed1cf0c07cf
const componentRoutes = {
component: App,
path: '/',
childRoutes: [
{
path: '/posts',
async getComponent(location: string, cb: Function) {
try {
const module = await import('./modules/posts/Posts');
cb(null, module.default);
} catch (e) {
errorLoading(e);
}
}
},
{
path: '/posts/:id',
async getComponent(location: string, cb: Function) {
try {
const module = await import('./modules/posts/SinglePost');
cb(null, module.default);
} catch (e) {
errorLoading(e);
}
}
}
]
};
if (process.env.NODE_ENV === 'production') {
(() => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js');
}
})();
require('offline-plugin/runtime').install();
}
import styled from 'styled-components';
const Card = styled.div`
height: 400px;
width: 300px;
background-color: #fff;
cursor: pointer;
`;
export default Card;
/** @flow */
import type { Post } from './Data';
// POSTS
type FetchPostAction = {
type: 'FETCH_SINGLE_POST',
post: Post
}
type FetchAllPostsAction = {
type: 'FETCH_ALL_POSTS',
posts: Array<Post>
}
type FetchSinglePostErrorAction = {
type: 'FETCH_SINGLE_POST_ERROR'
}
type SelectPostAction = {
type: 'SELECTED_POST',
id: string
}
export type Action =
| FetchPostAction
| FetchAllPostsAction
| FetchSinglePostErrorAction
| SelectPostAction
https://thinkful-workshop-webpack2-node-react.now.sh/
- Clone the repos
npm i
oryarn
npm run dev:s
oryarn dev:s
for start the servernpm run dev:c
oryarn dev:c
for start the clientlocalhost:9000
gonna open in your browser by webpack
When install new packages just run flow-typed install
For deploy I'm using Now from Zeit Who provided free hosting with HTTP2. I'm using a variables for the mongodb hosting. For set yours just
now secret add mongodb <urlinkhere>
Inside the packages.json
I have alias this is for change the name from now.
Just run yarn deploy
or npm run deploy
- Change webpack code splitting System.import for import()
- Add service worker
- Add offline caching
- Get smaller bundle