Project life manager, whatever project you are on π
Those are some basics utilities; feel free to propose more!
- Register a new project
- Add a or multiple client
- Create and send invoice
Install on your computer:
- Clone the repo
- If you don't have yarn
npm install -g yarn
- Download and install the packages
yarn
- Start locally yarn start
While developing, you will probably rely mostly on yarn start
; however, there are additional scripts at your disposal:
yarn <script> |
Description |
---|---|
start |
Serves your app at localhost:3000 |
build |
Builds the application to ./dist |
test |
Runs unit tests with Karma. See testing |
test:watch |
Runs test in watch mode to re-run tests when changed |
lint |
Lints the project for potential errors |
lint:fix |
Lints the project and fixes all correctable errors |
Let's go!
This starter kit is designed to get you up and running with a bunch of awesome front-end technologies.
Finally, This project wouldn't be possible without the help of our many contributors. What you see today is the product of hundreds changes made to keep up with an ever-evolving ecosystem. Thank you for all of your help.
- Requirements
- Installation
- Running the Project
- Project Structure
- Live Development
- Routing
- Testing
- Building for Production
- Deployment
- Thank You
- node
^5.0.0
- yarn
^0.23.0
or npm^3.0.0
After confirming that your environment meets the above requirements, you can create a new project based on react-redux-starter-kit
by doing the following:
$ git clone https://github.com/davezuko/react-redux-starter-kit.git <my-project-name>
$ cd <my-project-name>
When that's done, install the project dependencies. It is recommended that you use Yarn for deterministic dependency management, but npm install
will suffice.
$ yarn # Install project dependencies (or `npm install`)
After completing the installation step, you're ready to start the project!
$ yarn start # Start the development server (or `npm start`)
The project structure presented in this boilerplate is fractal, where functionality is grouped primarily by feature rather than file type. This structure is only meant to serve as a guide, it is by no means prescriptive. That said, it aims to represent generally accepted guidelines and patterns for building scalable applications. If you wish to read more about this pattern, please check out this awesome writeup by Justin Greenberg.
.
βββ build # All build-related code
βββ public # Static public assets (not imported anywhere in source code)
βββ server # Express application that provides webpack middleware
β βββ main.js # Server application entry point
βββ src # Application source code
β βββ index.html # Main HTML page container for app
β βββ main.js # Application bootstrap and rendering
β βββ normalize.js # Browser normalization and polyfills
β βββ components # Global Reusable Components
β βββ containers # Global Reusable Container Components
β βββ layouts # Components that dictate major page structure
β β βββ PageLayout # Global application layout in which to render routes
β βββ routes # Main route definitions and async split points
β β βββ index.js # Bootstrap main application routes with store
β β βββ Home # Fractal route
β β β βββ index.js # Route definitions and async split points
β β β βββ assets # Assets required to render components
β β β βββ components # Presentational React Components
β β β βββ routes ** # Fractal sub-routes (** optional)
β β βββ Counter # Fractal route
β β βββ index.js # Counter route definition
β β βββ container # Connect components to actions and store
β β βββ modules # Collections of reducers/constants/actions
β β βββ routes ** # Fractal sub-routes (** optional)
β βββ store # Redux-specific pieces
β β βββ createStore.js # Create and instrument redux store
β β βββ reducers.js # Reducer registry and injection
β βββ styles # Application-wide styles (generally settings)
βββ tests # Unit tests
Hot reloading is enabled by default when the application is running in development mode (yarn start
). This feature is implemented with webpack's Hot Module Replacement capabilities, where code updates can be injected to the application while it's running, no full reload required. Here's how it works:
-
For JavaScript modules, a code change will trigger the application to re-render from the top of the tree. Global state is preserved (i.e. redux), but any local component state is reset. This differs from React Hot Loader, but we've found that performing a full re-render helps avoid subtle bugs caused by RHL patching.
-
For Sass, any change will update the styles in realtime, no additional configuration or reload needed.
We recommend using the Redux DevTools Chrome Extension. Using the chrome extension allows your monitors to run on a separate thread and affords better performance and functionality. It comes with several of the most popular monitors, is easy to configure, filters actions, and doesn't require installing any packages in your project.
However, it's easy to bundle these developer tools locally should you choose to do so. First, grab the packages from npm:
yarn add --dev redux-devtools redux-devtools-log-monitor redux-devtools-dock-monitor
Then follow the manual integration walkthrough.
We use react-router
route definitions (<route>/index.js
) to define units of logic within our application. See the project structure section for more information.
To add a unit test, create a .spec.js
file anywhere inside of ./tests
. Karma and webpack will automatically find these files, and Mocha and Chai will be available within your test without the need to import them. Here are a few important plugins and packages available to you during testing:
Some of the assertions available from chai use magical getters. These are problematic for a few reasons:
- If you mistype a property name (e.g.
expect(false).to.be.tru
) then the expression evaluates to undefined, the magical getter on thetrue
is never run, and so your test silently passes. - By default, linters don't understand them and therefore mark them as unused expressions, which can be annoying.
Dirty Chai fixes this by converting these getters into callable functions. This way, if mistype an assertion, our attempt to invoke it will throw due to the property being undefined.
// This silently passes because the getter on `true` is never invoked!
it('should be true', () => {
expect(false).to.be.tru // evalutes to undefined :(
})
// Much better! Our assertion is invalid, so it throws rather than implicitly passing.
it('should be true', () => {
expect(false).to.be.tru() // `tru` is not defined!
})
Out of the box, this starter kit is deployable by serving the ./dist
folder generated by yarn build
. This project does not concern itself with the details of server-side rendering or API structure, since that demands a more opinionated structure that makes it difficult to extend the starter kit. The simplest deployment strategy is a static deployment.
Serve the application with a web server such as nginx by pointing it at your ./dist
folder. Make sure to direct incoming route requests to the root ./dist/index.html
file so that the client application will be loaded; react-router will take care of the rest. If you are unsure of how to do this, you might find this documentation helpful. The Express server that comes with the starter kit is able to be extended to serve as an API and more, but is not required for a static deployment.
This project wouldn't be possible without help from the community, so I'd like to highlight some of its biggest contributors. Thank you all for your hard work, you've made my life a lot easier and taught me a lot in the process.
- Justin Greenberg - For all of your PR's, getting us to Babel 6, and constant work improving our patterns.
- Roman Pearah - For your bug reports, help in triaging issues, and PR contributions.
- Spencer Dixon - For your creation of redux-cli.
- Jonas Matser - For your help in triaging issues and unending support in our Gitter channel.
And to everyone else who has contributed, even if you are not listed here your work is appreciated.