Build Extension

Rsbuild

Rspress builds documents based on Rsbuild.

Configure Rsbuild

Rsbuild provides a rich set of build configurations. You can customize these configurations through builderConfig. 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',
      },
    },
  },
});
TIP

You can learn more about the configuration options through Rsbuild - Config documentation.

Configure Rspack

You can configure Rspack through the tools.rspack option provided by Rsbuild:

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

export default defineConfig({
  builderConfig: {
    tools: {
      rspack(options) {
        // modify the rspack configuration
      },
    },
  },
});

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.