Bundler

VuePress has been using webpackBundler - 图1open in new window as the bundler to dev and build sites. Since VuePress v2, other tools like ViteBundler - 图2open in new window are also supported.

Although it is possible to create other bundler packages by community users, currently we only suggest to use the bundlers provided by VuePress team.

Webpack

When using the vuepressBundler - 图3open in new window package, the webpack bundler is installed:

  1. npm install -D vuepress

You can specify the name of the bundler to use in bundler option, or omit it because webpack is the default bundler. Then you can set options of webpack bundler via bundlerConfig option:

  • JS
  • TS
  1. module.exports = {
  2. bundler: '@vuepress/webpack',
  3. bundlerConfig: {
  4. // webpack bundler options
  5. },
  6. }
  1. import { defineUserConfig } from 'vuepress'
  2. import type { DefaultThemeOptions, WebpackBundlerOptions } from 'vuepress'
  3. export default defineUserConfig<DefaultThemeOptions, WebpackBundlerOptions>({
  4. bundler: '@vuepress/webpack',
  5. bundlerConfig: {
  6. // webpack bundler options
  7. },
  8. })

Vite

If you want to use Vite instead, you can switch to vuepress-viteBundler - 图4open in new window package:

  1. npm install -D vuepress-vite

Next, you need to specify the name of the bundler to use in bundler option. Then you can set options of vite bundler via bundlerConfig option:

  • JS
  • TS
  1. module.exports = {
  2. bundler: '@vuepress/vite',
  3. bundlerConfig: {
  4. // vite bundler options
  5. },
  6. }
  1. import { defineUserConfig } from 'vuepress-vite'
  2. import type { DefaultThemeOptions, ViteBundlerOptions } from 'vuepress-vite'
  3. export default defineUserConfig<DefaultThemeOptions, ViteBundlerOptions>({
  4. bundler: '@vuepress/vite',
  5. bundlerConfig: {
  6. // vite bundler options
  7. },
  8. })