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): switch to vite 3 and support clean urls #856

Merged
merged 125 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
75dcaa2
chore: update deps
brc-dd Jun 23, 2022
c90baae
feat: support esm ssr build (#707)
brc-dd Jun 23, 2022
7573246
fix: update DefaultTheme import
brc-dd Jun 23, 2022
5dbca1f
chore: make errors reproducible
brc-dd Jun 24, 2022
3dcb64c
chore: don't remove temp dir
brc-dd Jun 24, 2022
bedd7af
feat: use ESM in SSR
brc-dd Jun 24, 2022
57d782c
fix: ESM SSR (#855)
sapphi-red Jun 25, 2022
53a24ad
chore: simplify vue/server-renderer import
brc-dd Jun 25, 2022
dc0e1b3
chore: update deps
brc-dd Jun 25, 2022
dddcf15
fix: remove temp dir unless DEBUG is set
brc-dd Jun 25, 2022
7557701
refactor: simplify loadPageModule type
brc-dd Jun 25, 2022
288dfa4
fix: #412
brc-dd Jun 25, 2022
0227e0e
chore: update ports
brc-dd Jun 25, 2022
7787bbe
fix: show localhost instead of 127.0.0.1 in dev
brc-dd Jun 25, 2022
7ad269d
Merge pull request #859 from vuejs/main
brc-dd Jun 25, 2022
8d101ec
feat: allow specifying a setup function in Theme
brc-dd Jun 26, 2022
2a59b7e
docs: add information about setup in theme
brc-dd Jun 26, 2022
3ab7fe3
chore: update deps
brc-dd Jun 26, 2022
20450ee
Merge branch 'main' into chore/vite-3
brc-dd Jun 27, 2022
a2b0df0
Merge branch 'main' into chore/vite-3
brc-dd Jun 27, 2022
8d09a8c
chore: update deps
brc-dd Jun 27, 2022
d3fbbb9
chore: update deps
brc-dd Jun 28, 2022
fb0bac8
chore: update pnpm
brc-dd Jun 29, 2022
1e82501
chore(ci): update versions
brc-dd Jun 29, 2022
4c17cc7
Merge branch 'main' into chore/vite-3
brc-dd Jun 29, 2022
95b9a28
chore: update pnpm
brc-dd Jun 30, 2022
36a87b6
chore(ci): remove explicit version from pnpm/action-setup
brc-dd Jun 30, 2022
f5b54d8
Merge branch 'main' into chore/vite-3
brc-dd Jun 30, 2022
ee4c9f1
chore: update deps
brc-dd Jun 30, 2022
6adf9b4
docs: update docs/guide/getting-started.md
brc-dd Jul 1, 2022
1d097ce
chore: update docsearch
brc-dd Jul 1, 2022
057ae5e
chore: simplify
brc-dd Jul 1, 2022
50bb7ba
chore: format
brc-dd Jul 1, 2022
6155238
fix: type errors in sponsor components
brc-dd Jul 1, 2022
88a3982
Merge branch 'main' into chore/vite-3
brc-dd Jul 1, 2022
3702e04
Merge branch 'main' into chore/vite-3
brc-dd Jul 2, 2022
b7b662a
Merge branch 'main' into chore/vite-3
brc-dd Jul 2, 2022
b387aff
Merge branch 'main' into chore/vite-3
brc-dd Jul 2, 2022
a647bec
chore: lint
brc-dd Jul 2, 2022
fdb42cf
Merge branch 'main' into chore/vite-3
brc-dd Jul 3, 2022
4e4dd55
refactor: remove type casts
brc-dd Jul 3, 2022
fff3af8
Merge branch 'main' into chore/vite-3
brc-dd Jul 3, 2022
ba9aa72
fix(types): use `ComponentOptions` as a type
brc-dd Jul 4, 2022
952de91
refactor: remove @theme aliases
brc-dd Jul 4, 2022
37b89c0
Merge branch 'main' into chore/vite-3
brc-dd Jul 4, 2022
d6a9968
fix: don't customise asset file names
brc-dd Jul 5, 2022
c4c141e
Merge branch 'main' into chore/vite-3
brc-dd Jul 5, 2022
e9788e7
fix: wrong tsconfig path
brc-dd Jul 5, 2022
2a0ccc2
chore: update vite
brc-dd Jul 6, 2022
56229e4
feat/clean-urls (#929)
brc-dd Jul 7, 2022
d83e640
fix: merge conflicts in lockfile
brc-dd Jul 7, 2022
57e9603
feat: add frontmatter to markdown-it env
brc-dd Jul 7, 2022
5d337ca
Merge branch 'main' into chore/vite-3
brc-dd Jul 7, 2022
4e5d2c4
Merge branch 'main' into chore/vite-3
brc-dd Jul 8, 2022
11bfd20
chore: update deps
brc-dd Jul 8, 2022
c7bedfa
Merge branch 'main' into chore/vite-3
brc-dd Jul 8, 2022
18997b1
chore: update deps
brc-dd Jul 8, 2022
afeb388
Merge branch 'main' into chore/vite-3
brc-dd Jul 9, 2022
88ceca1
Merge branch 'main' into chore/vite-3
brc-dd Jul 9, 2022
a8f0083
fix: exclude vitepress from dep optimization
brc-dd Jul 10, 2022
fbff315
chore: update deps
brc-dd Jul 11, 2022
88fe9a0
Merge branch 'main' into chore/vite-3
brc-dd Jul 11, 2022
4048b70
Merge branch 'main' into chore/vite-3
brc-dd Jul 12, 2022
506bd13
Merge branch 'main' into chore/vite-3
brc-dd Jul 13, 2022
f73f766
chore: update deps
brc-dd Jul 13, 2022
466a113
Merge branch 'main' into chore/vite-3
brc-dd Jul 13, 2022
773e2e5
Merge branch 'main' into chore/vite-3
brc-dd Jul 14, 2022
40730f1
chore: update pnpm
brc-dd Jul 14, 2022
a2c9395
Update src/node/build/bundle.ts
brc-dd Jul 14, 2022
608bc71
Update src/client/theme-default/components/VPAlgoliaSearchBox.vue
brc-dd Jul 14, 2022
0e522e7
Merge branch 'main' into chore/vite-3
brc-dd Jul 14, 2022
5c2854f
revert: 952de911a6d8c1165d015aeb55ae53a75c1baa7a
brc-dd Jul 14, 2022
66be1de
feat: support using config.cjs/cts (#1000)
CHOYSEN Jul 17, 2022
0297b00
Merge branch 'main' into chore/vite-3
brc-dd Jul 18, 2022
085e09e
chore: update deps
brc-dd Jul 18, 2022
2ebeaf6
chore: update vite
brc-dd Jul 19, 2022
6039f23
Merge branch 'main' into chore/vite-3
brc-dd Jul 19, 2022
2172aac
Merge branch 'main' into chore/vite-3
brc-dd Jul 20, 2022
c9b330b
Merge branch 'main' into chore/vite-3
brc-dd Jul 21, 2022
e4ce593
Merge branch 'main' into chore/vite-3
brc-dd Jul 23, 2022
9300f6b
fix build
brc-dd Jul 23, 2022
0f5a8ec
chore: update deps
brc-dd Jul 23, 2022
38c281a
refactor: remove ts comment
brc-dd Jul 23, 2022
32db63f
Merge branch 'main' into chore/vite-3
brc-dd Jul 26, 2022
73ef948
chore: update deps
brc-dd Jul 27, 2022
96b4af8
Update docs/guide/getting-started.md
brc-dd Jul 27, 2022
1c7b4ae
Update src/client/theme-default/components/VPAlgoliaSearchBox.vue
brc-dd Jul 27, 2022
7d8e5e0
Merge branch 'main' into chore/vite-3
brc-dd Jul 28, 2022
b12a730
Merge branch 'main' into chore/vite-3
brc-dd Jul 29, 2022
9a7d30d
Merge branch 'main' into chore/vite-3
brc-dd Jul 29, 2022
1a73349
chore: update deps
brc-dd Jul 29, 2022
6053d83
chore: update engines
brc-dd Jul 30, 2022
e925283
chore: update deps
brc-dd Jul 30, 2022
771ca62
merge
brc-dd Aug 1, 2022
b9b1d30
Merge branch 'main' into chore/vite-3
brc-dd Aug 1, 2022
0e8a096
Merge branch 'main' into chore/vite-3
brc-dd Aug 1, 2022
c92c217
Merge branch 'main' into chore/vite-3
brc-dd Aug 2, 2022
3a19be7
Merge branch 'main' into chore/vite-3
brc-dd Aug 4, 2022
e3fdf4b
chore: update deps
brc-dd Aug 4, 2022
a63346b
Merge branch 'main' into chore/vite-3
brc-dd Aug 5, 2022
f105a2d
chore: update deps
brc-dd Aug 5, 2022
49e74b8
refactor: migrate to nodenext moduleResolution (#1136)
JounQin Aug 7, 2022
53c7484
chore: cleanup
brc-dd Aug 7, 2022
bbbda30
fix: failing builds on custom theme
brc-dd Aug 7, 2022
3b6f7aa
fix: make sitedata readonly on dev
brc-dd Aug 7, 2022
ba4f724
Merge branch 'main' into chore/vite-3
brc-dd Aug 7, 2022
eab8b87
refactor: switch to `cache.clear` from `reset`
brc-dd Aug 7, 2022
afa3aa8
chore: remove engines field
brc-dd Aug 9, 2022
58174fe
Merge branch 'main' into chore/vite-3
brc-dd Aug 10, 2022
ef227d1
fix: remove vitepress/ to vitepress/dist/ alias
brc-dd Aug 10, 2022
25ef797
Merge branch 'main' into chore/vite-3
brc-dd Aug 10, 2022
6504c41
chore: update deps
brc-dd Aug 10, 2022
ef548a9
chore: revert vue-tsc to old version
brc-dd Aug 10, 2022
0469ac6
chore: update deps
brc-dd Aug 14, 2022
8499005
revert: fix broken dev and eval warnings
brc-dd Aug 14, 2022
dfa2ae1
Merge branch 'main' into chore/vite-3
brc-dd Aug 14, 2022
1bd1894
Merge branch 'main' into chore/vite-3
brc-dd Aug 14, 2022
8636218
chore: restore vuePath alias
brc-dd Aug 16, 2022
ea12c3f
Merge branch 'main' into chore/vite-3
brc-dd Aug 16, 2022
d874c20
chore: update deps
brc-dd Aug 16, 2022
e0c04f9
chore: fix type
yyx990803 Aug 16, 2022
3b2d90a
fix: fix build for vite 3 + "type": "module"
yyx990803 Aug 17, 2022
0a501da
chore: ignore vue/server-renderer type for now
yyx990803 Aug 17, 2022
7e919f9
chore: more type fix
yyx990803 Aug 17, 2022
38f987b
Merge branch 'main' into chore/vite-3
brc-dd Aug 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The easiest way to start testing out VitePress is to tweak the VitePress docs. Y
$ pnpm run docs
```

After executing the above command, visit http://localhost:3000 and try modifying the source code. You'll get live update.
After executing the above command, visit http://localhost:5173 and try modifying the source code. You'll get live update.

If you don't need docs site up and running, you may start VitePress local dev environment with `pnpm run dev`.

Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Release

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@v3

- name: Create Release for Tag
id: release_tag
uses: yyx990803/release-tag@master
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ on:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16]
node-version: [14, 16, 18]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 7.0.1
uses: pnpm/action-setup@v2

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dist
node_modules
pnpm-global
TODOs.md
.temp
*.tgz
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/docs
*.md
*.vue
dist
Expand Down
2 changes: 1 addition & 1 deletion client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// be able to reference vite/client in project root.
/// <reference types="vite/client" />

export * from './dist/client'
export * from './dist/client/index.js'
12 changes: 6 additions & 6 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineConfig } from '../../src/node'

import { version } from '../../package.json'
import { defineConfig } from 'vitepress'
import { version } from 'vitepress/package.json'

export default defineConfig({
lang: 'en-US',
title: 'VitePress',
description: 'Vite & Vue powered static site generator.',

lastUpdated: true,
cleanUrls: 'without-subfolders',

themeConfig: {
nav: nav(),
Expand Down Expand Up @@ -58,9 +58,9 @@ function nav() {
{
text: 'Contributing',
link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md'
},
],
},
}
]
}
]
}

Expand Down
25 changes: 25 additions & 0 deletions docs/config/app-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,28 @@ export default {
titleTemplate: 'Vite & Vue powered static site generator'
}
```

## cleanUrls (Experimental)

- Type: `'disabled' | 'without-subfolders' | 'with-subfolders'`
- Default: `'disabled'`

Allows removing trailing `.html` from URLs and, optionally, generating clean directory structure. Available modes:

| Mode | Page | Generated Page | URL |
| :--------------------: | :-------: | :---------------: | :---------: |
| `'disabled'` | `/foo.md` | `/foo.html` | `/foo.html` |
| `'without-subfolders'` | `/foo.md` | `/foo.html` | `/foo` |
| `'with-subfolders'` | `/foo.md` | `/foo/index.html` | `/foo` |

::: warning

Enabling this may require additional configuration on your hosting platform. For it to work, your server must serve the generated page on requesting the URL (see above table) **without a redirect**.

:::

```ts
export default {
cleanUrls: 'with-subfolders'
}
```
4 changes: 4 additions & 0 deletions docs/config/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Place your configuration file at `.vitepress/config.js`. This is where all ViteP
└─ package.json
```

::: tip
You can also use any of `.ts`, `.cjs`, `.mjs`, `.cts`, `.mts` as the config file extension.
:::

VitePress comes with 2 types of configs. One is the [App Configs](./app-configs) which configures the site's fundamental features such as setting title of the site, or customize how markdown parser works. Second is the [Theme Config](./theme-configs) which configures the theme of the site, for example, adding a sidebar, or add features such as "Edit this page on GitHub" link.

There's also another configuration you may do in [Frontmatter](./frontmatter-configs). Frontmatter configs can override global configs defined on App Configs or Theme Configs for that specific page. However, there're several options that are only available at frontmatter as well.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If your site is to be served at a subdirectory (`https://example.com/subdir/`),
$ yarn docs:serve
```

The `serve` command will boot up a local static web server that will serve the files from `.vitepress/dist` at `http://localhost:5000`. It's an easy way to check if the production build looks fine in your local environment.
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.

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

Expand Down
20 changes: 3 additions & 17 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,7 @@ $ yarn add --dev vitepress vue
::: details Getting missing peer deps warnings?
`@docsearch/js` has certain issues with its peer dependencies. If you see some commands failing due to them, you can try this workaround for now:

On Yarn v2/v3, add this inside your rc file (`.yarnrc.yml` by default):
brc-dd marked this conversation as resolved.
Show resolved Hide resolved

```yaml
packageExtensions:
'@docsearch/react@*':
peerDependenciesMeta:
'@types/react':
optional: true
'react':
optional: true
'react-dom':
optional: true
```

On PNPM, add this in your `package.json`:
If using PNPM, add this in your `package.json`:

```json
"pnpm": {
Expand Down Expand Up @@ -90,7 +76,7 @@ Serve the documentation site in the local server.
$ yarn docs:dev
```

VitePress will start a hot-reloading development server at `http://localhost:3000`.
VitePress will start a hot-reloading development server at `http://localhost:5173`.

## Step. 4: Add more pages

Expand All @@ -104,7 +90,7 @@ Let's add another page to the site. Create a file name `getting-started.md` alon
└─ package.json
```

Then, try to access `http://localhost:3000/getting-started` and you should see the content of `getting-started` is shown.
Then, try to access `http://localhost:5173/getting-started.html` and you should see the content of `getting-started.md` is shown.

This is how VitePress works basically. The directory structure corresponds with the URL path. You add files, and just try to access it.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/migration-from-vitepress-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you're coming from VitePress 0.x version, there're several breaking changes d
- `children` key is now named `items`.
- Top level item may not contain `link` at the moment. We're planning to bring it back.
- `repo`, `repoLabel`, `docsDir`, `docsBranch`, `editLinks`, `editLinkText` are removed in favor of more flexible api.
- For adding GitHub link with icon to the nav, use [Social Links](./theme-nav.html#navigation-links) feature.
- For adding GitHub link with icon to the nav, use [Social Links](./theme-nav#navigation-links) feature.
- For adding "Edit this page" feature, use [Edit Link](./theme-edit-link) feature.
- `lastUpdated` option is now split into `config.lastUpdated` and `themeConfig.lastUpdatedText`.
- `carbonAds.carbon` is changed to `carbonAds.code`.
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/migration-from-vuepress.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Images

Unlike VuePress, VitePress handles [`base`](/guide/asset-handling.html#base-url) of your config automatically when you use static image.
Unlike VuePress, VitePress handles [`base`](./asset-handling#base-url) of your config automatically when you use static image.

Hence, now you can render images without `img` tag.

Expand All @@ -14,7 +14,7 @@ Hence, now you can render images without `img` tag.
```

::: warning
For dynamic images you still need `withBase` as shown in [Base URL guide](/guide/asset-handling.html#base-url).
For dynamic images you still need `withBase` as shown in [Base URL guide](./asset-handling#base-url).
:::

Use `<img.*withBase\('(.*)'\).*alt="([^"]*)".*>` regex to find and replace it with `![$2]($1)` to replace all the images with `![](...)` syntax.
Expand Down
6 changes: 6 additions & 0 deletions docs/guide/theme-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface Theme {
Layout: Component // Vue 3 component
NotFound?: Component
enhanceApp?: (ctx: EnhanceAppContext) => void
setup?: () => void
}

interface EnhanceAppContext {
Expand Down Expand Up @@ -65,6 +66,11 @@ export default {
// router is VitePress' custom router. `siteData` is
// a `ref` of current site-level metadata.
}

setup() {
// this function will be executed inside VitePressApp's
// setup hook. all composition APIs are available here.
}
}
```

Expand Down
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"private": true,
"name": "vitepress-docs"
"devDependencies": {
"vitepress": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/configured/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from '../../../src/node'
import { defineConfig } from 'vitepress'

export default defineConfig({
title: 'Configured Example',
Expand Down