Skip to content

Commit

Permalink
refactor(core): normalize core app structure
Browse files Browse the repository at this point in the history
BREAKING CHANGE: config `templateSSR` is renamed to `templateBuild`
  • Loading branch information
meteorlxy committed Dec 27, 2021
1 parent 66943fb commit 6952acf
Show file tree
Hide file tree
Showing 32 changed files with 448 additions and 416 deletions.
206 changes: 104 additions & 102 deletions docs/reference/config.md
Expand Up @@ -149,7 +149,7 @@ Rendered as:

- Type: `string`

- Default: `'@vuepress/default'`
- Default: `'@vuepress/theme-default'`

- Details:

Expand Down Expand Up @@ -204,7 +204,7 @@ module.exports = {

- Type: `string`

- Default: `'@vuepress/webpack'`
- Default: `'@vuepress/bundler-vite'`

- Details:

Expand All @@ -216,7 +216,7 @@ module.exports = {
- [Guide > Bundler](../guide/bundler.md)

::: tip
When using [vuepress-vite](https://www.npmjs.com/package/vuepress-vite) package, the default bundler will be set to `'@vuepress/vite'`.
When using [vuepress-webpack](https://www.npmjs.com/package/vuepress-webpack) package, the default bundler will be set to `'@vuepress/bundler-webpack'`.
:::

### bundlerConfig
Expand All @@ -234,7 +234,7 @@ When using [vuepress-vite](https://www.npmjs.com/package/vuepress-vite) package,
- [Bundlers > Webpack](./bundler/webpack.md)
- [Bundlers > Vite](./bundler/vite.md)

## Directory Config
## Common Config

### dest

Expand Down Expand Up @@ -279,6 +279,106 @@ When using [vuepress-vite](https://www.npmjs.com/package/vuepress-vite) package,
- Also see:
- [Guide > Assets > Public Files](../guide/assets.md#public-files)

### debug

- Type: `boolean`

- Default: `false`

- Details:

Enable debug mode or not.

This would be helpful for developers. Also, we are using [debug](https://github.com/visionmedia/debug) package for debug logging, which can be enabled via `DEBUG=vuepress*` environment variable.

### pagePatterns

- Type: `string[]`

- Default: `['**/*.md', '!.vuepress', '!node_modules']`

- Details:

Specify the patterns of files you want to be resolved as pages. The patterns are relative to the source directory.

## Dev Config

### host

- Type: `string`

- Default: `'0.0.0.0'`

- Details:

Specify the host to use for the dev server.

### port

- Type: `number`

- Default: `8080`

- Details:

Specify the port to use for the dev server.

### open

- Type: `boolean`

- Default: `false`

- Details:

Whether to open the browser after dev-server had been started.

### templateDev

- Type: `string`

- Default: `'@vuepress/client/templates/index.dev.html'`

- Details:

Specify the HTML template to be used for dev.

## Build Config

### shouldPreload

- Type: `((file: string, type: string) => boolean)) | boolean`

- Default: `true`

- Details:

A function to control what files should have `<link rel="preload">` resource hints generated. Set to `true` or `false` to enable or disable totally.

By default, only those files that are required by current page will be preloaded. So you can keep it `true` in most cases.

### shouldPrefetch

- Type: `((file: string, type: string) => boolean)) | boolean`

- Default: `false`

- Details:

A function to control what files should have `<link rel="prefetch">` resource hints generated. Set to `true` or `false` to enable or disable for all files.

If you set it to `true`, all files that required by other pages will be prefetched. This is good for small sites, which will speed up the navigation, but it might not be a good idea if you have lots of pages in your site.

### templateBuild

- Type: `string`

- Default: `'@vuepress/client/templates/index.build.html'`

- Details:

Specify the HTML template to be used for build.

## Markdown Config

### markdown
Expand Down Expand Up @@ -634,104 +734,6 @@ You should not configure it unless you understand what it is for.

Should be a subset of [markdown.anchor.level](#markdownanchor) option to ensure the links in the TOC are existed.

## Development Config

### debug

- Type: `boolean`

- Default: `false`

- Details:

Enable debug mode or not.

This would be helpful for developers. Also, we are using [debug](https://github.com/visionmedia/debug) package for debug logging, which can be enabled via `DEBUG=vuepress*` environment variable.

### host

- Type: `string`

- Default: `'0.0.0.0'`

- Details:

Specify the host to use for the dev server.

### port

- Type: `number`

- Default: `8080`

- Details:

Specify the port to use for the dev server.

### open

- Type: `boolean`

- Default: `false`

- Details:

Whether to open the browser after dev-server had been started.

### pagePatterns

- Type: `string[]`

- Default: `['**/*.md', '!.vuepress', '!node_modules']`

- Details:

Specify the patterns of files you want to be resolved as pages. The patterns are relative to the source directory.

### templateDev

- Type: `string`

- Default: `'@vuepress/client/templates/index.dev.html'`

- Details:

Specify the HTML template to be used for dev.

### templateSSR

- Type: `string`

- Default: `'@vuepress/client/templates/index.ssr.html'`

- Details:

Specify the HTML template to be used for build (SSR).

### shouldPreload

- Type: `((file: string, type: string) => boolean)) | boolean`

- Default: `true`

- Details:

A function to control what files should have `<link rel="preload">` resource hints generated. Set to `true` or `false` to enable or disable totally.

By default, only those files that are required by current page will be preloaded. So you can keep it `true` in most cases.

### shouldPrefetch

- Type: `((file: string, type: string) => boolean)) | boolean`

- Default: `false`

- Details:

A function to control what files should have `<link rel="prefetch">` resource hints generated. Set to `true` or `false` to enable or disable for all files.

If you set it to `true`, all files that required by other pages will be prefetched. This is good for small sites, which will speed up the navigation, but it might not be a good idea if you have lots of pages in your site.

## Plugin Config

### plugins
Expand Down
30 changes: 15 additions & 15 deletions docs/reference/node-api.md
Expand Up @@ -112,23 +112,31 @@ const dev = async () => {

## App Properties

### version
### options

- Type: `string`
- Type: `AppOptions`

- Details:

Version of VuePress app, i.e. version of `@vuepress/core` package.
Options of VuePress app.

### options
The options come from the `config` argument in [createBuildApp](#createbuildapp) / [createDevApp](#createdevapp), while all optional fields will be filled with a default value.

- Type: `AppOptions`
### siteData

- Type: `SiteData`

- Details:

Options of VuePress app.
Site data that set by user, including all the [site config](./config.md#site-config), which will be used in client side.

The options come from the `config` argument in [createBuildApp](#createbuildapp) / [createDevApp](#createdevapp), while all optional fields will be filled with a default value.
### version

- Type: `string`

- Details:

Version of VuePress app, i.e. version of `@vuepress/core` package.

### env.isBuild

Expand All @@ -154,14 +162,6 @@ const dev = async () => {

Environment flag used to identify whether the debug mode is enabled.

### siteData

- Type: `SiteData`

- Details:

Site data that set by user, including all the [site config](./config.md#site-config), which will be used in client side.

### markdown

- Type: `MarkdownIt`
Expand Down

0 comments on commit 6952acf

Please sign in to comment.