Skip to content

Commit

Permalink
feat(build): add preview as an alias for serve in cli (#1651)
Browse files Browse the repository at this point in the history
* feat(build): add preview as an alias for serve in cli
* docs: recommend using preview instead of serve
  • Loading branch information
brc-dd committed Nov 30, 2022
1 parent dc59662 commit 4ba33da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/guide/deploying.md
Expand Up @@ -10,7 +10,7 @@ The following guides are based on some shared assumptions:
{
"scripts": {
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs"
"docs:preview": "vitepress preview docs"
}
}
```
Expand All @@ -34,22 +34,22 @@ If your site is to be served at a subdirectory (`https://example.com/subdir/`),
- Once you've built the docs, you can test them locally by running:

```sh
$ yarn docs:serve
$ yarn docs:preview
```

The `serve` command will boot up a local static web server that will serve the files from `.vitepress/dist` at `http://localhost:4173`. It's an easy way to check if the production build looks fine in your local environment.
The `preview` command will boot up a local static web server that will serve the files from `.vitepress/dist` at `http://localhost:4173`. It's an easy way to check if the production build looks fine in your local environment.

- You can configure the port of the server by passing `--port` as an argument.

```json
{
"scripts": {
"docs:serve": "vitepress serve docs --port 8080"
"docs:preview": "vitepress preview docs --port 8080"
}
}
```

Now the `docs:serve` method will launch the server at `http://localhost:8080`.
Now the `docs:preview` method will launch the server at `http://localhost:8080`.

## Netlify, Vercel, AWS Amplify, Cloudflare Pages, Render

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/getting-started.md
Expand Up @@ -63,7 +63,7 @@ Add some scripts to `package.json`.
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs"
"docs:preview": "vitepress preview docs"
},
...
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -62,20 +62,20 @@
"format": "prettier --check --write .",
"format-fail": "prettier --check .",
"check": "run-s format-fail build test",
"test": "run-p --aggregate-output test-unit test-serve test-build",
"test": "run-p --aggregate-output test-unit test-preview test-build",
"test-unit": "vitest run -r __tests__/unit",
"test-serve": "vitest run -r __tests__/e2e",
"test-build": "VITE_TEST_BUILD=1 pnpm test-serve",
"debug-serve": "DEBUG=1 vitest -r __tests__/e2e",
"debug-build": "VITE_TEST_BUILD=1 pnpm debug-serve",
"test-preview": "vitest run -r __tests__/e2e",
"test-build": "VITE_TEST_BUILD=1 pnpm test-preview",
"debug-preview": "DEBUG=1 vitest -r __tests__/e2e",
"debug-build": "VITE_TEST_BUILD=1 pnpm debug-preview",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release": "node scripts/release.js",
"docs": "run-p dev docs-dev",
"docs-dev": "wait-on -d 100 dist/node/cli.js && node ./bin/vitepress dev docs",
"docs-debug": "node --inspect-brk ./bin/vitepress dev docs",
"docs-build": "run-s build docs-build-only",
"docs-build-only": "node ./bin/vitepress build docs",
"docs-serve": "node ./bin/vitepress serve docs"
"docs-preview": "node ./bin/vitepress preview docs"
},
"dependencies": {
"@docsearch/css": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/node/cli.ts
Expand Up @@ -32,7 +32,7 @@ if (!command || command === 'dev') {
console.error(c.red(`build error:\n`), err)
process.exit(1)
})
} else if (command === 'serve') {
} else if (command === 'serve' || command === 'preview') {
serve(argv).catch((err) => {
console.error(c.red(`failed to start server. error:\n`), err)
process.exit(1)
Expand Down

0 comments on commit 4ba33da

Please sign in to comment.