- git clone https://github.com/kumarankit1234/react-starter-kit.git .
- If you want to remove the git history then do rm -rf .git .
- cd react-starter-kit.
- For dev build with webpack dev server use:
yarn start
- For production build use:
yarn build
.
- Development server using webpack dev server.
- Optimized prod and dev build.
- SCSS supported.
- ES6 supported.
- React router v4 integrated.
- Autoprefixer for css properties built in.
- Redux integrated with thunk middlewares to support action as a function.
-
Added a basic webpack config just to add entry and output path of the bundle files.
-
Added HTMLWebpackPlugin to automatically generate the html files with all the output js files added to it as a script tag.
-
Added babel transpiler for ES6 code.
-
Used index.ejs instead of index.html to prevent htmlwebpackplugin to add the same script multiple times on index.html.
-
Used watch to prevent running webpack build everytime after file change.
-
Used react to render a div. Used babel-preset-react to transpile react specific code to js.
-
Removed not required options param of babel loader since we already use babelrc file to pass params.
-
Used css and style loader to include css in Jsx
-
Removed webpack watch and using webpack-dev-server instead because watch require us to refresh browser each time we make any changes. webpack dev server automatically refreshes the browser everytime there is any change and a new build is made. Need to figure out a way to prevent a full refresh because the app may lose state if using react/redux on full refresh
-
Used sass loader for sass files.
-
Used postcss loader and its autoprefixer plugin to add prefix to css for all browser support.
-
Used react component. Added module.hot check for react component for supporting hmr. Used babel plugin transform to use class property.
-
Used the router v4 to make routes on the client side. It allows declarative routing, so we dont need to have a whole routes file at one place in our application. We can add routes inside any component. Reference: https://reacttraining.com/react-router/core/guides/philosophy. This is causing one issue. When we are on some route say /about and we refresh the browser then we get a 404 not found error. The network call says that the main.bundle.js that is being fetched from the server is from the route /home/main.bundle.js and this route does not exist on the dev server. Need to figure out a way to fix this.
-
Added public path option in the output section of webpack config to always load the assets(Js file) from the root directory of the server.
-
Added separate config file for prod and dev build. Need to optimize the prod build. Reference: https://webpack.js.org/guides/production/
-
Used webpack merge to separate the common config of dev and prod into a common file to avoid code duplication.
-
Used Uglijy Js Plugin to minify the production javascript build. Reference: https://github.com/mishoo/UglifyJS2/tree/harmony. The defaults options are well suited so i didn't pass any parameters to the plugin. This plugin does a lot of optimization to the code.
-
Used Define plugin to define environment. The DefinePlugin allows you to create global constants which can be configured at compile time. This can be useful for allowing different behavior between development builds and release builds.
-
Used redux methods to create a store, subscribe to it and update the component on change. Created a simple reducer for the same.
-
Passed store as a props to the child component and created the store in the parent component.
-
Used context to create a Provider component that passes the store to all its children and grandchildrens as context. So now we dont need to pass store explicitly to any child.
-
Used Provider of react-redux instead of creating our own.
-
The pattern of a component subscribing to store changes like our own Home Component is so common that react-redux has a HOC for the same. It's called
Connect
. Used it to create the Home component. -
Moved the store creation logic to a separate file.
-
Created one more component to be able to learn how to split reducers based on different keys of the state using the
Combine reducer.
. -
Created a separate file for the initial state of the app.
-
Wrapped the store dispatch to add custom logging. This is is route to learning middlewares in redux.
-
Added one more wrapper around store to handle async params to dispatch.
-
Created a middlewares function that execute all the middleware.
-
Used redux method applyMiddlewares and passed it as an enhancer param to createStore.
-
Used thunk middleware to handle cases when the action is a function instead of a plain object and redux logger.