Skip to content

Commit

Permalink
feat(client): add __VUEPRESS_BASE__ constant
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Dec 9, 2022
1 parent 89503e4 commit fe047fe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/reference/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ To shim the types of these constants in client side code, add `@vuepress/client/

Version of VuePress core package.

### `__VUEPRESS_BASE__`

- Type: `string`

- Details:

The [base](./config.md#base) option from config.

### `__VUEPRESS_DEV__`

- Type: `boolean`
Expand Down
8 changes: 8 additions & 0 deletions docs/zh/reference/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@

VuePress Core 的版本号。

### `__VUEPRESS_BASE__`

- 类型: `string`

- 详情:

配置中的 [base](./config.md#base) 字段。

### `__VUEPRESS_DEV__`

- 类型: `boolean`
Expand Down
1 change: 1 addition & 0 deletions packages/bundler-vite/src/plugins/mainPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const resolveDefine = async ({
}): Promise<UserConfig['define']> => {
const define: UserConfig['define'] = {
__VUEPRESS_VERSION__: JSON.stringify(app.version),
__VUEPRESS_BASE__: JSON.stringify(app.options.base),
__VUEPRESS_DEV__: JSON.stringify(!isBuild),
__VUEPRESS_SSR__: JSON.stringify(isServer),
// @see http://link.vuejs.org/feature-flags
Expand Down
1 change: 1 addition & 0 deletions packages/bundler-webpack/src/config/handlePluginDefine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const handlePluginDefine = async ({
config.plugin('define').use(webpack.DefinePlugin, [
{
__VUEPRESS_VERSION__: JSON.stringify(app.version),
__VUEPRESS_BASE__: JSON.stringify(app.options.base),
__VUEPRESS_DEV__: JSON.stringify(!isBuild),
__VUEPRESS_SSR__: JSON.stringify(isServer),
// @see http://link.vuejs.org/feature-flags
Expand Down
1 change: 1 addition & 0 deletions packages/client/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare const __VUEPRESS_VERSION__: string
declare const __VUEPRESS_BASE__: string
declare const __VUEPRESS_DEV__: boolean
declare const __VUEPRESS_SSR__: boolean
declare const __VUE_HMR_RUNTIME__: Record<string, any>
Expand Down

0 comments on commit fe047fe

Please sign in to comment.