Build Extension

Rsbuild

Rspress builds documents based on Rsbuild.

Rsbuild provides flexible build configurations, you can use builderConfig to customize these configurations. For example, change the output directory to doc_dist:

rspress.config.ts
import { defineConfig } from 'rspress/config';

export default defineConfig({
  builderConfig: {
    output: {
      distPath: {
        root: 'doc_dist',
      },
    },
    tools: {
      rspack(options) {
        // change rspack's options
      },
    },
  },
});
TIP

You can learn more configurations through the Rsbuild - Config documentation.

Note that Rspress only supports Rspack bundler, so some configurations related to webpack will not work, such as tools.webpack. Of course, you can use the tools.rspack to customize the Rspack config.

MDX Compilation

The compilation of MDX in the framework is based on unified, and you can add related compilation plugins through markdown configuration. for example :

rspress.config.ts
import { defineConfig } from 'rspress/config';

export default defineConfig({
  markdown: {
    // It's necessary to use JS version compiler
    mdxRs: false,
    remarkPlugins: [
      [
        require('remark-autolink-headings'),
        {
          behavior: 'wrap',
        },
      ],
    ],
    rehypePlugins: [require('rehype-slug')],
  },
});
WARNING

Only the JS version of the MDX compiler supports compilation plugins.