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: README.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,23 +4,31 @@ This is an opinionated base [Sails v1](https://sailsjs.com) application, using W
4
4
5
5
## Main Features
6
6
7
-
+[Automatic (incoming) request logging, via Sails models / hooks.](#request-logging)
8
-
+[Setup for Webpack auto-reload dev server.](#local-dev)
7
+
+ Automatic (incoming) request logging, via Sails models / hooks.
8
+
+ Setup for Webpack auto-reload dev server.
9
9
+ Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
10
10
+ Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
11
11
12
-
###Request Logging
12
+
## Request Logging
13
13
Automatic incoming request logging, is a 2 part process. First, the [`request-logger` hook](api/hooks/request-logger.js) gathers info from the quest, and creates a new [`RequestLog` record](api/models/RequestLog.js), making sure to mask anything that may be sensitive, such as passwords. Then, a custom response gathers information from the response, again, scrubbing sensitive data (using the [customToJSON](https://sailsjs.com/documentation/concepts/models-and-orm/model-settings?identity=#customtojson) feature of Sails models) to prevent leaking of password hashes, or anything else that should never be publicly accessible. The [`keepModelsSafe` helper](api/helpers/keep-models-safe.js) and the custom responses (such as [ok](api/responses/ok.js) or [serverError](api/responses/serverError.js)) are responsible for the final leg of request logs.
14
14
15
-
###Using Webpack
15
+
## Using Webpack
16
16
#### Local Dev
17
17
The script `npm run open:client` will start the auto-reloading Webpack development server, and open a browser window.
18
18
19
19
#### Remote Builds
20
-
The script `npm run build` will make Webpack build all the proper assets into the `.tmp` folder. Sails will serve assets from this folder.
20
+
The script `npm run build` will make Webpack build all the proper assets into the `.tmp/public` folder. Sails will serve assets from this folder.
21
21
22
22
If you want to build assets, but retain spaces / tabs for debugging, you can use `npm run build:dev`.
23
23
24
+
#### Configuration
25
+
The webpack configuration can be found in the `config/webpack` folder. The majority of the configuration can be found in [`common.config.js`](config/webpack/common.config.js). Then, the other 3 files, such as [`dev.config.js`](config/webpack/dev.config.js) extend the `common.config.js` file.
26
+
27
+
## Building with React
28
+
React source files live in the `assets/src` folder. It is structured in such a way, where the `index.jsx` is really only used for local development (to help Webpack serve up the correct "app"). Then, there are the individual "apps", [main](assets/src/main.jsx) and [admin](assets/src/admin.jsx). These files are used as Webpack "[entry points](https://webpack.js.org/concepts/entry-points/)", to create 2 separate application bundles.
29
+
30
+
In a remote environment, Sails will look at the first subdirectory requested, and use that to determine which `index.html` file it needs to actually return. So, in this case, the "main" application will get built in `.tmp/public/main`, where the CSS is `.tmp/public/main/bundle.css`, the JavaScript is `.tmp/public/main/bundle.js`, and the HTML is `.tmp/public/main/index.html`. To view the main application, one would just go to `http://mydomain/` which gets redirected to `/main` (because need to know what application we are using), and now Sails will serve the `main` application. Where as, if one were to go to `http://mydomain/admin`, Sails would now serve the `admin` application bundle.
0 commit comments