Skip to content

Commit bb5e745

Browse files
committed
docs(readme.md): update readme file with the latest changes
1 parent 8a510d4 commit bb5e745

File tree

2 files changed

+42
-53
lines changed

2 files changed

+42
-53
lines changed

README.md

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,59 @@
11
# smooth-server
22

3-
## Installation and Usage
3+
A simple local development HTTP server optimized for productivity.
44

5-
The recommended installation method is a local NPM install for your project:
6-
```bash
5+
## Installation
6+
7+
#### Local Installation
8+
```sh
79
$ npm install smooth-server --save-dev
10+
$ yarn add smooth-server --dev
811
```
12+
After installing, add following "script" entry within your project's `package.json` file:
913

10-
...and add a "script" entry within your project's `package.json` file:
11-
```
12-
# Inside package.json...
14+
```json
15+
{
1316
"scripts": {
1417
"dev": "smooth-server"
1518
},
16-
17-
"scripts": {
18-
"dev": "smooth-server --config path/config.json"
19-
},
19+
}
2020
```
21-
22-
With the above script entry, you can then start `smoot-server` via:
23-
```bash
21+
With the above script entry, you can then start `smooth-server` via:
22+
```sh
2423
$ npm run dev
2524
```
25+
You can also specify a configuration file:
26+
```json
27+
{
28+
"scripts": {
29+
"dev": "smooth-server --config path/config.json"
30+
},
31+
}
32+
```
33+
If a config file is not found the default port will be `3333` and the listened files will be `["./**/*.{html,htm,css,js}"]`.
2634

27-
### Global Installation
28-
29-
smoot-server can be also installed globally, if preferred:
30-
```bash
31-
$ npm install -g smoot-server
32-
33-
# To run:
35+
#### Global Installation
36+
```sh
37+
$ npm install -g smooth-server
38+
```
39+
You can run it directly from the command line:
40+
```sh
3441
$ smooth-server
3542
$ smooth-server --config path/smooth-server.config.json
3643
```
3744

3845
## Custom Configuration
3946

40-
The default behavior serves from the current folder, opens a browser, and applies a HTML5 route fallback to `./index.html`.
47+
The default behavior serves from the current directory, opens a browser, and applies a HTML5 route fallback to `./index.html`.
4148

42-
smoot-server uses [BrowserSync](https://www.browsersync.io/), and allows for configuration overrides via a local `bs-config.json` or `bs-config.js` file in your project.
49+
`smooth-server` uses [BrowserSync](https://www.browsersync.io/), and allows for configuration overrides via a local `bs-config.json` or `bs-config.js` file in your project. If these files do not exist, it will use the default configuration.
4350

44-
You can provide custom path to your config file via `-c` or `--config=` run time options:
45-
```bash
51+
You can provide custom path to your config file via `-c` or `--config=` command line options:
52+
```sh
4653
smooth-server -c configs/my-bs-config.js
4754
```
4855

49-
For example, to change the server port, watched file paths, and base directory for your project, create a `bs-config.json` in your project's folder:
56+
#### Configuring via `bs-config.json`
5057
```json
5158
{
5259
"port": 8081,
@@ -55,7 +62,8 @@ For example, to change the server port, watched file paths, and base directory f
5562
}
5663
```
5764

58-
A more complicated example with modifications to the server middleware can be done with a `bs-config.js` file, which requires the `module.exports = { ... };` syntax:
65+
#### Configuring via `bs-config.js`
66+
This approach is more flexible and allows using JavaScript instead of a static JSON.
5967
```js
6068
module.exports = {
6169
server: {
@@ -67,37 +75,20 @@ module.exports = {
6775
};
6876
```
6977

70-
The `bs-config.js` file may also export a function that receives the smoot-server Browsersync instance as its only argument. While not required, the return value of this function will be used to extend the default smoot-server configuration.
71-
```js
72-
module.exports = function(bs) {
73-
74-
return {
75-
server: {
76-
middleware: {
77-
// overrides the second middleware default with new settings
78-
1: require('connect-history-api-fallback')({
79-
index: '/index.html',
80-
verbose: true
81-
})
82-
}
83-
}
84-
};
78+
Full list of BrowserSync options can be found in its docs: <http://www.browsersync.io/docs/options/>
8579

86-
};
87-
```
80+
> **Note:** When using middleware overrides the specific middleware module must be installed in your project. For the above example, `connect-history-api-fallback` package needs to be installed in your project:
8881
89-
**NOTE:** Keep in mind that when using middleware overrides the specific middleware module must be installed in your project. For the above example, you'll need to do:
90-
```bash
82+
```sh
9183
$ npm install connect-history-api-fallback --save-dev
9284
```
9385

94-
...otherwise you'll get an error similar to:
95-
```
86+
Or else, you will get an error:
87+
```shell
9688
Error: Cannot find module 'connect-history-api-fallback'
9789
```
9890

99-
Another example: To remove one of the [default middlewares](./lib/config-defaults.js), such as `connect-logger`, you can set it's array index to `null`:
100-
91+
> **TIP:** To remove one of the default middlewares such as `connect-logger`, set its array index to `null`:
10192
```js
10293
module.exports = {
10394
server: {
@@ -106,6 +97,4 @@ module.exports = {
10697
}
10798
}
10899
};
109-
```
110-
111-
A list of the entire set of BrowserSync options can be found in its docs: <http://www.browsersync.io/docs/options/>
100+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smooth-server",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Little node server based on lite-server and browsersync",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)