From 4ba33dac60b8b091627eb3e9c2347da0aa5efb82 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Wed, 30 Nov 2022 18:00:57 +0530 Subject: [PATCH] feat(build): add preview as an alias for serve in cli (#1651) * feat(build): add preview as an alias for serve in cli * docs: recommend using preview instead of serve --- docs/guide/deploying.md | 10 +++++----- docs/guide/getting-started.md | 2 +- package.json | 12 ++++++------ src/node/cli.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/guide/deploying.md b/docs/guide/deploying.md index 2c703bb935da..a5eebdb9b030 100644 --- a/docs/guide/deploying.md +++ b/docs/guide/deploying.md @@ -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" } } ``` @@ -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 diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index eebed4509811..2c1d037cbb84 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -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" }, ... } diff --git a/package.json b/package.json index 6e26b8785c8c..33c4b1a3991f 100644 --- a/package.json +++ b/package.json @@ -62,12 +62,12 @@ "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", @@ -75,7 +75,7 @@ "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", diff --git a/src/node/cli.ts b/src/node/cli.ts index 0d992fab8e41..0bd1cb3ecb0c 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -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)