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
* Switch to Fractal pattern with CSS modules based on [redux-starter-kit](https://github.com/davezuko/react-redux-starter-kit)
* `redux-firebasev3` updated to v0.1.6
* coverage being sent to Codecov
* Outputted `README.md` matches new application format
* Deploy section of outputted `README.md` matches choice
* Tests updated to match new format
Run `npm start` to start live reloading development server
35
+
Run `npm run dev` to start live reloading development server
36
36
37
37
### Production
38
38
@@ -81,7 +81,6 @@ To deploy:
81
81
*`HEROKU_KEY` - Your Heroku API key
82
82
*`HEROKU_APP` - Your Heroku App name
83
83
84
-
85
84
## Sub generators
86
85
87
86
Sub generators are included to help speed up the application building process. You can run a sub-generator by calling `yo react-firebase:<name of sub-generator> <param1>`.
@@ -108,16 +107,12 @@ A component is best for things that will be reused in multiple places. Our examp
108
107
109
108
```javascript
110
109
importReact, { Component, PropTypes } from'react'
111
-
import'./Car.scss'
110
+
importclassesfrom'./Car.scss'
112
111
113
112
exportdefaultclassCarextendsComponent {
114
-
constructor (props) {
115
-
super(props)
116
-
}
117
-
118
113
render () {
119
114
return (
120
-
<div className="Car">
115
+
<div className={classes['container']}>
121
116
122
117
</div>
123
118
)
@@ -147,41 +142,63 @@ Creates a folder within `/containers` that matches the name provided. Below is t
If everything works, you should see the following:
39
+
40
+
<imgsrc="http://i.imgur.com/zR7VRG6.png?2" />
41
+
42
+
While developing, you will probably rely mostly on `npm start`; however, there are additional scripts at your disposal:
43
+
44
+
|`npm run <script>`|Description|
45
+
|------------------|-----------|
46
+
|`start`|Serves your app at `localhost:3000`. HMR will be enabled in development.|
47
+
|`compile`|Compiles the application to disk (`~/dist` by default).|
48
+
|`dev`|Same as `npm start`, but enables nodemon for the server as well.|
49
+
|`test`|Runs unit tests with Karma and generates a coverage report.|
50
+
|`test:dev`|Runs Karma and watches for changes to re-run tests; does not generate coverage reports.|
51
+
|`build`|Runs linter, tests, and then, on success, compiles your application to disk.|
52
+
|`build:dev`|Same as `build` but overrides `NODE_ENV` to "development".|
53
+
|`build:prod`|Same as `build` but overrides `NODE_ENV` to "production".|
54
+
|`lint`|Lint all `.js` files.|
55
+
|`lint:fix`|Lint and fix all `.js` files. [Read more on this](http://eslint.org/docs/user-guide/command-line-interface.html#fix).|
56
+
57
+
## Application Structure
58
+
59
+
The application structure presented in this 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).
60
+
61
+
```
62
+
.
63
+
├── bin # Build/Start scripts
64
+
├── blueprints # Blueprint files for redux-cli
65
+
├── build # All build-related configuration
66
+
│ └── webpack # Environment-specific configuration files for webpack
67
+
├── config # Project configuration settings
68
+
├── server # Express application that provides webpack middleware
69
+
│ └── main.js # Server application entry point
70
+
├── src # Application source code
71
+
│ ├── index.html # Main HTML page container for app
72
+
│ ├── main.js # Application bootstrap and rendering
73
+
│ ├── components # Global Reusable Presentational Components
74
+
│ ├── containers # Global Reusable Container Components
75
+
│ ├── layouts # Components that dictate major page structure
76
+
│ ├── redux # "Ducks" location...
77
+
│ │ └── modules # reducer, action, creators not part of a route
78
+
│ ├── routes # Main route definitions and async split points
79
+
│ │ ├── index.js # Bootstrap main application routes with store
**We recommend using the [Redux DevTools Chrome Extension](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd).**
100
+
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.
101
+
102
+
However, adding the DevTools components to your project is simple. First, grab the packages from npm:
103
+
104
+
```bash
105
+
npm i --save-dev redux-devtools redux-devtools-log-monitor redux-devtools-dock-monitor
106
+
```
107
+
108
+
Then follow the [manual integration walkthrough](https://github.com/gaearon/redux-devtools/blob/master/docs/Walkthrough.md).
109
+
110
+
### Routing
111
+
We use `react-router`[route definitions](https://github.com/reactjs/react-router/blob/master/docs/API.md#plainroute) (`<route>/index.js`) to define units of logic within our application. See the [application structure](#application-structure) section for more information.
112
+
113
+
## Testing
114
+
To add a unit test, simply create a `.spec.js` file anywhere in `~/tests`. Karma will pick up on these files automatically, and Mocha and Chai will be available within your test without the need to import them. Coverage reports will be compiled to `~/coverage` by default. If you wish to change what reporters are used and where reports are compiled, you can do so by modifying `coverage_reporters` in `~/config/index.js`.
115
+
116
+
## Deployment
117
+
Out of the box, this starter kit is deployable by serving the `~/dist` folder generated by `npm run deploy` (make sure to specify your target `NODE_ENV` as well). This project does not concern itself with the details of server-side rendering or API structure, since that demands an opinionated structure that makes it difficult to extend the starter kit. However, if you do need help with more advanced deployment strategies, here are a few tips:
118
+
119
+
### Static Deployments
120
+
If you are serving the application via a web server such as nginx, make sure to direct incoming routes to the root `~/dist/index.html` file and let react-router take care of the rest. If you are unsure of how to do this, you might find [this documentation](https://github.com/reactjs/react-router/blob/master/docs/guides/Histories.md#configuring-your-server) helpful. The Express server that comes with the starter kit is able to be extended to serve as an API or whatever else you need, but that's entirely up to you.
121
+
122
+
## Build System
123
+
124
+
### Configuration
125
+
126
+
Default project configuration can be found in `~/config/index.js`. Here you'll be able to redefine your `src` and `dist` directories, adjust compilation settings, tweak your vendor dependencies, and more. For the most part, you should be able to make changes in here **without ever having to touch the actual webpack build configuration**.
127
+
128
+
If you need environment-specific overrides (useful for dynamically setting API endpoints, for example), you can edit `~/config/environments.js` and define overrides on a per-NODE_ENV basis. There are examples for both `development` and `production`, so use those as guidelines. Here are some common configuration options:
129
+
130
+
|Key|Description|
131
+
|---|-----------|
132
+
|`dir_src`|application source code base path|
133
+
|`dir_dist`|path to build compiled application to|
134
+
|`server_host`|hostname for the Express server|
135
+
|`server_port`|port for the Express server|
136
+
|`compiler_devtool`|what type of source-maps to generate (set to `false`/`null` to disable)|
137
+
|`compiler_vendor`|packages to separate into to the vendor bundle|
138
+
139
+
Webpack is configured to make use of [resolve.root](http://webpack.github.io/docs/configuration.html#resolve-root), which lets you import local packages as if you were traversing from the root of your `~/src` directory. Here's an example:
These are global variables available to you anywhere in your source code. If you wish to modify them, they can be found as the `globals` key in `~/config/index.js`. When adding new globals, make sure you also add them to `~/.eslintrc`.
153
+
154
+
|Variable|Description|
155
+
|---|---|
156
+
|`process.env.NODE_ENV`|the active `NODE_ENV` when the build started|
157
+
|`__DEV__`|True when `process.env.NODE_ENV` is `development`|
158
+
|`__PROD__`|True when `process.env.NODE_ENV` is `production`|
159
+
|`__TEST__`|True when `process.env.NODE_ENV` is `test`|
160
+
161
+
### Styles
162
+
163
+
Both `.scss` and `.css` file extensions are supported out of the box. After being imported, styles will be processed with [PostCSS](https://github.com/postcss/postcss) for minification and autoprefixing, and will be extracted to a `.css` file during production builds.
164
+
165
+
### Server
166
+
167
+
This starter kit comes packaged with an Express server. It's important to note that the sole purpose of this server is to provide `webpack-dev-middleware` and `webpack-hot-middleware` for hot module replacement. Using a custom Express app in place of [webpack-dev-server](https://github.com/webpack/webpack-dev-server) makes it easier to extend the starter kit to include functionality such as API's, universal rendering, and more -- all without bloating the base boilerplate.
168
+
169
+
### Production Optimization
170
+
171
+
Babel is configured to use [babel-plugin-transform-runtime](https://www.npmjs.com/package/babel-plugin-transform-runtime) so transforms aren't inlined. In production, webpack will extract styles to a `.css` file, minify your JavaScript, and perform additional optimizations such as module deduplication.
172
+
173
+
## Learning Resources
174
+
175
+
*[Starting out with react-redux-starter-kit](https://suspicious.website/2016/04/29/starting-out-with-react-redux-starter-kit/) is an introduction to the components used in this starter kit with a small example in the end.
176
+
177
+
16
178
### Production
17
179
18
180
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.
19
181
20
182
### Deployment
21
183
22
-
#### Firebase
23
-
24
184
1. Login to [Firebase](firebase.google.com) (or Signup if you don't have an account) and create a new project
25
185
2. Install cli: `npm i -g firebase-tools`
26
186
3. Login: `firebase login`
@@ -33,27 +193,9 @@ Build code before deployment by running `npm run build`. There are multiple opti
33
193
6. Confirm Firebase config by running locally: `firebase serve`
34
194
7. Deploy to firebase: `firebase deploy`
35
195
36
-
#### AWS S3
37
-
38
-
Selecting AWS S3 from the deploy options when running the generator adds deploy configs in `.travis.yml`.
39
-
40
-
1. Get your AWS Key and Secret from the AWS Console Credentials page
41
-
2. Set the following environment vars within the Travis-CI repo settings page:
42
-
* AWS_KEY - Your AWS key
43
-
* AWS_SECRET - Your AWS secret
44
-
* BUCKET - Your S3 Bucket
45
196
46
-
#### Heroku
47
197
48
-
Selecting [Heroku](http://heroku.com) from the deploy options when running the generator adds a `Procfile` as well as deploy configs in `.travis.yml` for out of the box deployment.
49
198
50
-
To deploy to [Heroku](http://heroku.com) through [Travis-CI](http://travis-ci.org):
51
-
1. Enable Repo on Travis-CI Account
52
-
2. Get API Key from Heroku Dashboard
53
-
3. Create a new App (this name will be used in travis env var)
54
-
4. Set the following environment vars within the Travis-CI repo settings page:
0 commit comments