Config Reference

Basic Config

base

  • Type: string
  • Default: /

The base URL the site will be deployed at. You will need to set this if you plan to deploy your site under a sub path, for example, GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/, then you should set base to "/bar/". It should always start and end with a slash.

The base is automatically prepended to all the URLs that start with / in other options, so you only need to specify it once.

Also see:

title

  • Type: string
  • Default: undefined

Title for the site. This will be the prefix for all page titles, and displayed in the navbar in the default theme.

description

  • Type: string
  • Default: undefined

Description for the site. This will render as a <meta> tag in the page HTML.

head

  • Type: Array
  • Default: []

Extra tags to inject into the page HTML <head>. You can specify each tag in the form of [tagName, { attrName: attrValue }, innerHTML?]. For example, to add a custom favicon:

  1. module.exports = {
  2. head: [
  3. ['link', { rel: 'icon', href: '/logo.png' }]
  4. ]
  5. }

host

  • Type: string
  • Default: '0.0.0.0'

Specify the host to use for the dev server.

port

  • Type: number
  • Default: 8080

Specify the port to use for the dev server.

temp

  • Type: string
  • Default: /path/to/@vuepress/core/.temp

Specify the temporary directory for client.

dest

  • Type: string
  • Default: .vuepress/dist

Specify the output directory for vuepress build. If a relative path is specified, it will be resolved based on process.cwd().

locales

  • Type: { [path: string]: Object }
  • Default: undefined

Specify locales for i18n support. For more details, see the guide on Internationalization.

shouldPrefetch

  • Type: Function
  • Default: () => true

A function to control what files should have <link rel="prefetch"> resource hints generated. See shouldPrefetchConfig Reference - 图1.

cache

  • Type: boolean|string
  • Default: true

VuePress uses cache-loaderConfig Reference - 图2 by default to greatly speed up the compilation of webpack.

You can use this option to specify the path to the cache, and can also remove the cache before each build by setting it to false.

TIP

You can also use this option through the CLI:

  1. vuepress dev docs --cache .cache # set cache path
  2. vuepress dev docs --no-cache # remove cache before each build.

extraWatchFiles

  • Type: Array
  • Default: []

Specify extra files to watch.

You can watch any file if you want. File changes will trigger vuepress rebuilding and real-time updates.

  1. module.exports = {
  2. extraWatchFiles: [
  3. '.vuepress/foo.js', // Relative path usage
  4. '/path/to/bar.js' // Absolute path usage
  5. ]
  6. }

patterns

  • Type: Array
  • Default: ['/*.md', '/*.vue']

Specify which pattern of files you want to be resolved.

Styling

palette.styl

To apply simple overrides to the styling of the default presetConfig Reference - 图3 or define some variables to use later, you can create a .vuepress/styles/palette.styl file.

There are some predefined variables you can tweak:

  1. // colors
  2. $accentColor = #3eaf7c
  3. $textColor = #2c3e50
  4. $borderColor = #eaecef
  5. $codeBgColor = #282c34
  6. $arrowBgColor = #ccc
  7. $badgeTipColor = #42b983
  8. $badgeWarningColor = darken(#ffe564, 35%)
  9. $badgeErrorColor = #DA5961
  10. // layout
  11. $navbarHeight = 3.6rem
  12. $sidebarWidth = 20rem
  13. $contentWidth = 740px
  14. $homePageWidth = 960px
  15. // responsive breakpoints
  16. $MQNarrow = 959px
  17. $MQMobile = 719px
  18. $MQMobileNarrow = 419px

Note

You should ONLY define variables in this file. Since palette.styl will be imported at the end of the root Stylus config file, as a config, several files will use it, so once you wrote styles here, your style would be duplicated by multiple times.

index.styl

VuePress provides a convenient way to add extra styles. You can create a .vuepress/styles/index.styl file for that. This is a StylusConfig Reference - 图4 file but you can use normal CSS syntax as well.

  1. .content {
  2. font-size 30px
  3. }

Also see:

Theming

theme

  • Type: string
  • Default: undefined

Specify this to use a custom theme.

Also see:

themeConfig

  • Type: Object
  • Default: {}

Provide config options to the used theme. The options will vary depending on the theme you are using.

Also see:

Pluggable

plugins

  • Type: Object|Array
  • Default: undefined

Please check out Plugin > Using a plugin to learn how to use a plugin.

Markdown

markdown.lineNumbers

  • Type: boolean
  • Default: undefined

Whether to show line numbers to the left of each code blocks.

Also see:

markdown.slugify

  • Type: Function
  • Default: sourceConfig Reference - 图5

Function for transforming header texts into slugs. Changing this affects the ids/links generated for header anchors, table of contents and sidebar links.

markdown.anchor

  • Type: Object
  • Default: { permalink: true, permalinkBefore: true, permalinkSymbol: '#' }

Options for markdown-it-anchorConfig Reference - 图6. (Note: prefer markdown.slugify to customize header ids.)

  • Type: Object
  • Default: { target: '_blank', rel: 'noopener noreferrer' }

The key and value pair will be added to <a> tags that point to an external link. The default option will open external links in a new window.

markdown.toc

  • Type: Object
  • Default: { includeLevel: [2, 3] }

Options for markdown-it-table-of-contentsConfig Reference - 图7. (Note: prefer markdown.slugify to customize header ids.)

markdown.plugins

You can install any markdown-it plugins through markdown.plugins option. It’s similar with using VuePress plugins. You can either use Babel style or object style. The markdown-it- prefix is optional and can omit in the list.

  1. module.exports = {
  2. markdown: {
  3. plugins: [
  4. '@org/foo', // equals to @org/markdown-it-foo if exists
  5. ['markdown-it-bar', {
  6. // provide options here
  7. }]
  8. ]
  9. }
  10. }

Or

  1. module.exports = {
  2. markdown: {
  3. plugins: {
  4. '@org/foo': {}
  5. 'markdown-it-bar': {
  6. // provide options here
  7. }
  8. }
  9. }
  10. }

markdown.extendMarkdown

  • Type: Function
  • Default: undefined

A function to edit default config or apply extra plugins to the markdown-itConfig Reference - 图8 instance used to render source files. For example:

  1. module.exports = {
  2. markdown: {
  3. extendMarkdown: md => {
  4. md.set({ breaks: true })
  5. md.use(require('markdown-it-xxx'))
  6. }
  7. }
  8. }

TIP

This option is also included in Plugin API.

markdown.extractHeaders

  • Type: Array
  • Default: ['h2', 'h3']

While preparing the page, headers are extracted from the Markdown file and stored in this.$page.headers. By default, VuePress will extract h2 and h3 elements for you. You can override the headers it pulls out in your markdown options.

  1. module.exports = {
  2. markdown: {
  3. extractHeaders: [ 'h2', 'h3', 'h4' ]
  4. }
  5. }

Build Pipeline

Configuring CSS Pre-processors

VuePress comes with built-in webpack config for the CSS pre-processors listed below. For more information on installation these or pre-processors without built-in support, see Using Pre-Processors for more information.

postcss

  • Type: Object
  • Default: { plugins: [require('autoprefixer')] }

Options for postcss-loaderConfig Reference - 图9. Note specifying this value will overwrite autoprefixer and you will need to include it yourself.

Stylus

  • Type: Object
  • Default: { preferPathResolver: 'webpack' }

Options for stylus-loaderConfig Reference - 图10.

scss

  • Type: Object
  • Default: {}

Options for sass-loaderConfig Reference - 图11 to load *.scss files.

Sass

  • Type: Object
  • Default: { indentedSyntax: true }

Options for sass-loaderConfig Reference - 图12 to load *.sass files.

less

  • Type: Object
  • Default: {}

Options for less-loaderConfig Reference - 图13.

configureWebpack

  • Type: Object | Function
  • Default: undefined

Edit the internal webpack config. If the value is an Object, it will be merged into the final config using webpack-mergeConfig Reference - 图14; If the value is a function, it will receive the config as the 1st argument and an isServer flag as the 2nd argument. You can either mutate the config directly, or return an object to merge:

  1. module.exports = {
  2. configureWebpack: (config, isServer) => {
  3. if (!isServer) {
  4. // mutate the config for client
  5. }
  6. }
  7. }

chainWebpack

  • Type: Function
  • Default: undefined

Edit the internal webpack config with webpack-chainConfig Reference - 图15.

  1. module.exports = {
  2. chainWebpack: (config, isServer) => {
  3. // config is an instance of ChainableConfig
  4. }
  5. }

Browser Compatibility

evergreen

  • Type: boolean | Function
  • Default: false

Set to true if you are only targeting evergreen browsers. This will disable ES5 transpilation and polyfills for IE, and result in faster builds and smaller files.