mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 19:03:38 +02:00
feat(v2): add support for serve command (#3080)
* add support for serve command * add serve to init * use existing choosePort function * add --host * add more docs * add docs to deployment
This commit is contained in:
parent
6a511b805a
commit
a51a56ec42
11 changed files with 134 additions and 5 deletions
|
@ -111,3 +111,14 @@ Deploys your site with [GitHub Pages](https://pages.github.com/). Check out the
|
|||
| --- | --- | --- |
|
||||
| `--out-dir` | `build` | The full path for the new output directory, relative to the current workspace. |
|
||||
| `--skip-build` | `false` | Deploy website without building it. This may be useful when using custom deploy script. |
|
||||
|
||||
### `docusaurus serve`
|
||||
|
||||
Serve your built website localy.
|
||||
|
||||
| Name | Default | Description |
|
||||
| --- | --- | --- |
|
||||
| `--port` | `3000` | Use specified port |
|
||||
| `--dir` | `build` | The full path for the output directory, relative to the current workspace |
|
||||
| `--build` | `false` | Build website before serving |
|
||||
| `--host` | `localhost` | Specify a host to use. For example, if you want your server to be accessible externally, you can use `--host 0.0.0.0`. |
|
||||
|
|
|
@ -13,6 +13,29 @@ Once it finishes, the static files will be generated within the `build/` directo
|
|||
|
||||
You can deploy your site to static site hosting services such as [Vercel](https://vercel.com/), [GitHub Pages](https://pages.github.com/), [Netlify](https://www.netlify.com/), [Render](https://render.com/static-sites), and [Surge](https://surge.sh/help/getting-started-with-surge). Docusaurus sites are statically rendered so they work without JavaScript too!
|
||||
|
||||
## Testing Build Local
|
||||
|
||||
It is important to test build before deploying to a production. Docusaurus includes a [`docusaurus serve`](cli.md#docusaurus-serve) command to test build localy.
|
||||
|
||||
```bash npm2yarn
|
||||
npm run serve
|
||||
```
|
||||
|
||||
## Self Hosting
|
||||
|
||||
:::warning
|
||||
|
||||
It is not the most performant solution
|
||||
|
||||
:::
|
||||
|
||||
Docusaurus can be self hosted using [`docusaurus serve`](cli.md#docusaurus-serve). Change port using `--port` and `--host` to change host.
|
||||
|
||||
```bash npm2yarn
|
||||
npm run serve --build --port 80 --host 0.0.0.0
|
||||
|
||||
```
|
||||
|
||||
## Deploying to GitHub Pages
|
||||
|
||||
Docusaurus provides an easy way to publish to [GitHub Pages](https://pages.github.com/). Which is hosting that comes for free with every GitHub repository.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue