|
1 | 1 | # @microsoft/gulp-core-build-serve |
2 | 2 |
|
| 3 | + |
3 | 4 | `gulp-core-build-serve` is a `gulp-core-build` subtask for testing/serving web content on the localhost, and live reloading it when things change. |
4 | 5 |
|
5 | 6 | [](https://badge.fury.io/js/%40microsoft%2Fgulp-core-build-serve) |
6 | 7 | [](https://travis-ci.org/Microsoft/gulp-core-build-serve) [](https://david-dm.org/Microsoft/gulp-core-build-serve) |
7 | 8 |
|
8 | | -# Tasks |
9 | | -## ServeTask |
| 9 | +# ServeTask |
| 10 | +A task which spins up two servers, one for serving files in the project, and another for |
| 11 | +mocking out an API server to run on a different port. |
| 12 | + |
| 13 | +## Usage |
| 14 | +`--nobrowser` will stop the browser from automatically launching. |
| 15 | + |
| 16 | +`--port X` will use X as the currently active port. |
| 17 | + |
| 18 | +## Config |
| 19 | +### api |
| 20 | +This configuration has two options. If it is undefined, no API endpoint is created. |
10 | 21 |
|
11 | | -### Description |
| 22 | +Default: `undefined` |
| 23 | + |
| 24 | +### port |
| 25 | +The port to run the API server on. |
| 26 | + |
| 27 | +### entryPath |
| 28 | +The path to the API file. This file should export an object of the following interface: |
12 | 29 |
|
13 | | -### Config |
14 | 30 | ```typescript |
15 | | -interface IServeTaskConfig { |
16 | | - api?: { |
17 | | - port: number, |
18 | | - entryPath: string |
19 | | - }; |
20 | | - https: boolean; |
21 | | - initialPage: string; |
22 | | - port: number; |
23 | | - keyPath: string; |
24 | | - certPath: string; |
25 | | - pfxPath: string; |
26 | | - tryCreateDevCertificate: boolean; |
| 31 | +interface IApiMap { |
| 32 | + [ route: string ]: Function; |
27 | 33 | } |
28 | 34 | ``` |
29 | | -* ** |
30 | 35 |
|
31 | | -Usage (and defaults): |
32 | | -```typescript |
33 | | -let build = require('gulp-core-build'); |
34 | | -let serve = require('gulp-core-build-serve'); |
35 | | - |
36 | | -build.task('serve', serve); |
37 | | - |
38 | | -serve.setConfig({ |
39 | | - api: null, |
40 | | - initialPage: '/index.html', |
41 | | - port: 4321, |
42 | | - https: false, |
43 | | - tryCreateDevCertificate: false, |
44 | | - keyPath: undefined, |
45 | | - certPath: undefined, |
46 | | - pfxPath: undefined |
47 | | - } |
48 | | -); |
49 | | -``` |
| 36 | +### initialPage |
| 37 | +The initial URL to load. This is ignored if the `--nobrowser` option is specified. |
| 38 | + |
| 39 | +Default: `'/index.html'` |
| 40 | + |
| 41 | +### port |
| 42 | +The port to serve on. |
| 43 | + |
| 44 | +Default: `4321` |
| 45 | + |
| 46 | +### https |
| 47 | +A boolean determining whether HTTPS mode should be turned on. |
| 48 | + |
| 49 | +Default: `false` |
50 | 50 |
|
51 | | -## TrustCertTask |
| 51 | +### keyPath |
| 52 | +When the `https` option is `true`, this is the path to the HTTPS key |
52 | 53 |
|
53 | | -### Description |
54 | | -This task gnerates and trusts a development certificate. The certificate is self-signed |
| 54 | +Default: `undefined` |
| 55 | + |
| 56 | +### certPath |
| 57 | +Path to the HTTPS cert |
| 58 | + |
| 59 | +Default: `undefined` |
| 60 | + |
| 61 | +### pfxPath |
| 62 | +Path to the HTTPS PFX cert |
| 63 | + |
| 64 | +Default: `undefined` |
| 65 | + |
| 66 | +### tryCreateDevCertificate |
| 67 | +If true, when gulp-core-build-serve is initialized and a dev certificate doesn't already exist and hasn't been |
| 68 | +specified, attempt to generate one and trust it automatically. |
| 69 | + |
| 70 | +Default: `false` |
| 71 | + |
| 72 | +# ReloadTask |
| 73 | +## Usage |
| 74 | +If this task is configured, whenever it is triggered it will tell `gulp-connect` to reload the page. |
| 75 | + |
| 76 | +## Config |
| 77 | +*This task doesn't have any configuration options.* |
| 78 | + |
| 79 | +# TrustCertTask |
| 80 | +## Usage |
| 81 | +This task generates and trusts a development certificate. The certificate is self-signed |
55 | 82 | and stored, along with its private key, in the user's home directory. On Windows, it's |
56 | 83 | trusted as a root certification authority in the user certificate store. On macOS, it's |
57 | 84 | trusted as a root cert in the keychain. On other platforms, the certificate is generated |
58 | 85 | and signed, but the user must trust it manually. See ***Development Certificate*** below for |
59 | 86 | more information. |
60 | 87 |
|
61 | | -### Config |
62 | | - |
| 88 | +## Config |
63 | 89 | *This task doesn't have any configuration options.* |
64 | 90 |
|
65 | | -## UntrustCertTask |
66 | | - |
67 | | -### Description |
| 91 | +# UntrustCertTask |
| 92 | +## Usage |
68 | 93 | On Windows, this task removes the certificate with the expected serial number from the user's |
69 | 94 | root certification authorities list. On macOS, it finds the SHA signature of the certificate |
70 | 95 | with the expected serial number and then removes that certificate from the keychain. On |
71 | 96 | other platforms, the user must untrust the certificate manually. On all platforms, |
72 | 97 | the certificate and private key are deleted from the user's home directory. See |
73 | 98 | ***Development Certificate*** below for more information. |
74 | 99 |
|
75 | | -### Config |
76 | | - |
| 100 | +## Config |
77 | 101 | *This task doesn't have any configuration options.* |
78 | 102 |
|
79 | 103 | # Development Certificate |
|
0 commit comments