Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): add preview as an alias for serve in cli #1651

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/guide/deploying.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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