Build Extension

Modern.js Builder

Rspress builds documents based on the Rspack mode of Modern.js Builder.

Modern.js Builder 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) {
        // 修改 rspack 的配置
      },
    },
  },
});
TIP

You can learn more configurations through the Modern.js Builder - API 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: {
    remarkPlugins: [
      [
        require('remark-autolink-headings'),
        {
          behavior: 'wrap',
        },
      ],
    ],
    rehypePlugins: [require('rehype-slug')],
  },
});
WARNING

Only the JS version of the MDX compiler supports compilation plugins. This means that if you have enabled the mdx-rs compiler, you need to remove the markdown.experimenalMdxRs: true configuration item in rspress config file.