You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/complete/material/README.md
+39-65
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,19 @@
1
-
# react-redux-firebase Complete Material Example
1
+
# material
2
2
3
3
[![License][license-image]][license-url]
4
4
[![Code Style][code-style-image]][code-style-url]
5
5
6
-
## What is Shown
6
+
## Table of Contents
7
7
8
-
* Route protection using `redux-auth-wrapper`
9
-
* Data input/validation using `redux-form`
10
-
* Async & Sync route loading
11
-
* Real CI and Deployment settings (including `prod` and `stage` environments)
12
-
* Using different instances of Firebase based on environment
8
+
1.[Features](#features)
9
+
1.[Requirements](#requirements)
10
+
1.[Getting Started](#getting-started)
11
+
1.[Application Structure](#application-structure)
12
+
1.[Development](#development)
13
+
1.[Routing](#routing)
14
+
1.[Configuration](#configuration)
15
+
1.[Production](#production)
16
+
1.[Deployment](#deployment)
13
17
14
18
## Requirements
15
19
@@ -40,9 +44,9 @@ While developing, you will probably rely mostly on `npm start`; however, there a
40
44
41
45
|`npm run <script>`|Description|
42
46
|-------------------|-----------|
43
-
|`start`|Serves your app at `localhost:3000` and displays [Webpack Dashboard](https://github.com/FormidableLabs/webpack-dashboard)|
44
-
|`start:simple`|Serves your app at `localhost:3000`without [Webpack Dashboard](https://github.com/FormidableLabs/webpack-dashboard)|
45
-
|`build`|Builds the application to ./dist|
47
+
|`start`|Serves your app at `localhost:3000`with automatic refreshing and hot module replacement|
48
+
|`start:dist`|Builds the application to `./dist` then serves at `localhost:3000`using `firebase serve`|
49
+
|`build`|Builds the application to `./dist`|
46
50
|`lint`|[Lints](http://stackoverflow.com/questions/8503559/what-is-linting) the project for potential errors|
47
51
|`lint:fix`|Lints the project and [fixes all correctable errors](http://eslint.org/docs/user-guide/command-line-interface.html#fix)|
48
52
@@ -52,7 +56,6 @@ While developing, you will probably rely mostly on `npm start`; however, there a
52
56
53
57
There are multiple configuration files:
54
58
55
-
* Project Path Configuration -`project.config.js`
56
59
* Firebase Project Configuration (including settings for how `src/config.js` is built on CI) -`.firebaserc`
57
60
* Project Configuration used within source (can change based on environment variables on CI) -`src/config.js`
58
61
* Cloud Functions Local Configuration -`functions/.runtimeconfig.json`
@@ -61,22 +64,20 @@ More details in the [Application Structure Section](#application-structure)
61
64
62
65
## Application Structure
63
66
64
-
The application structure presented inthis boilerplate is **fractal**, where functionality is grouped primarily by feature rather than file type. Please note, however, that 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](https://github.com/davezuko/react-redux-starter-kit/wiki/Fractal-Project-Structure) by [Justin Greenberg](https://github.com/justingreenberg).
67
+
The application structure presented inthis boilerplate is **fractal**, where functionality is grouped primarily by feature rather than file type. Please note, however, that 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.
65
68
66
69
```
67
-
├── build # All build-related configuration
70
+
├── public # All build-related configuration
71
+
│ ├── index.html # Main HTML page container for app
68
72
│ ├── scripts # Scripts used within the building process
69
-
│ ├── karma.config.js # Test configuration for Karma
70
-
│ └── webpack.config.js # Environment-specific configuration files for webpack
71
-
├── server # Express application that provides webpack middleware
│ └── utils # General Utilities (used throughout application)
98
+
│ │ ├── components.js # Utilities for building/implementing react components (often used in enhancers)
99
+
│ │ ├── form.js # For forms (often used in enhancers that use redux-form)
100
+
│ │ └── router.js # Utilities for routing such as those that redirect back to home if not logged in
101
+
├── tests # Unit tests
102
+
├── .env.local # Environment settings for when running locally
103
+
├── .eslintignore # ESLint ignore file
104
+
├── .eslintrc.js # ESLint configuration
101
105
├── .firebaserc # Firebase Project configuration settings (including ci settings)
102
-
└── tests # Unit tests
106
+
├── database.rules.json # Rules for Firebase Real Time Database
107
+
├── firebase.json # Firebase Service settings (Hosting, Functions, etc)
108
+
├── firestore.indexes.json # Indexs for Cloud Firestore
109
+
├── firestore.rules # Rules for Cloud Firestore
110
+
└── storage.rules # Rules for Cloud Storage For Firebase
103
111
```
104
112
105
-
### Routing
113
+
## Routing
114
+
106
115
We use `react-router-dom` [route matching](https://reacttraining.com/react-router/web/guides/basic-components/route-matching) (`<route>/index.js`) to define units of logic within our application. The application routes are defined within `src/routes/index.js`, which loads route settings which live in each route's `index.js`. The component with the suffix `Page` is the top level component of each route (i.e. `HomePage` is the top level component for `Home` route).
107
116
108
117
There are two types of routes definitions:
109
118
110
-
#### Sync Routes
119
+
### Sync Routes
111
120
112
121
The most simple way to define a route is a simple object with`path` and `component`:
113
122
@@ -123,7 +132,7 @@ export default {
123
132
}
124
133
```
125
134
126
-
#### Async Routes
135
+
### Async Routes
127
136
128
137
Routes can also be seperated into their own bundles which are only loaded when visiting that route, which helps decrease the size of your main application bundle. Routes that are loaded asynchronously are defined using `react-loadable`:
129
138
@@ -147,41 +156,6 @@ With this setting, the name of the file (called a "chunk") is defined as part of
147
156
148
157
More about how routing works is available in [the react-router-dom docs](https://reacttraining.com/react-router/web/guides/quick-start).
149
158
150
-
## Production
151
-
152
-
Build code before deployment by running `npm run build`. There are multiple options below for types of deployment, if you are unsure, checkout the Firebase section.
153
-
154
-
### Deployment
155
-
156
-
157
-
1. Install Firebase Command Line Tool:`npm i -g firebase-tools`
158
-
159
-
#### CIDeploy (recommended)
160
-
161
-
**Note**: Config forthis is located within
162
-
`firebase-ci` has been added to simplify the CI deployment process. All that is required is providing authentication with Firebase:
163
-
164
-
1. Login:`firebase login:ci` to generate an authentication token (will be used to give Travis-CI rights to deploy on your behalf)
165
-
1.Set`FIREBASE_TOKEN` environment variable within Travis-CI environment
166
-
1. Run a build on CI
167
-
168
-
If you would like to deploy to different Firebase instances for different branches (i.e. `prod`), change `ci` settings within `.firebaserc`.
169
-
170
-
For more options on CI settings checkout the [firebase-ci docs](https://github.com/prescottprue/firebase-ci)
171
-
172
-
#### Manual deploy
173
-
174
-
1. Run `firebase:login`
175
-
1. Initialize project with`firebase init` then answer:
176
-
* What file should be used for Database Rules?->`database.rules.json`
177
-
* What do you want to use as your public directory?->`build`
178
-
* Configure as a single-page app (rewrite all urls to /index.html)?->`Yes`
179
-
* What Firebase project do you want to associate as default?->**your Firebase project name**
180
-
1. Build Project:`npm run build`
181
-
1. Confirm Firebase config by running locally:`firebase serve`
182
-
1. Deploy to Firebase (everything including Hosting and Functions):`firebase deploy`
183
-
184
-
**NOTE:** You can use `firebase serve` to test how your application will work when deployed to Firebase, but make sure you run `npm run build` first.
0 commit comments