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
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`.
41
48
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.
43
50
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
46
53
smooth-server -c configs/my-bs-config.js
47
54
```
48
55
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`
50
57
```json
51
58
{
52
59
"port": 8081,
@@ -55,7 +62,8 @@ For example, to change the server port, watched file paths, and base directory f
55
62
}
56
63
```
57
64
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.
59
67
```js
60
68
module.exports= {
61
69
server: {
@@ -67,37 +75,20 @@ module.exports = {
67
75
};
68
76
```
69
77
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/>
85
79
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:
88
81
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:
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`:
101
92
```js
102
93
module.exports= {
103
94
server: {
@@ -106,6 +97,4 @@ module.exports = {
106
97
}
107
98
}
108
99
};
109
-
```
110
-
111
-
A list of the entire set of BrowserSync options can be found in its docs: <http://www.browsersync.io/docs/options/>
0 commit comments