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',
      },
    },
  },
});

Rspress also provides the builderPlugins config to register Rsbuild plugins. You can leverage Rsbuild's extensive plugin ecosystem to enhance and extend your build capabilities.

For example, add Google analytics through rsbuild-plugin-google-analytics:

rspress.config.ts
import { defineConfig } from 'rspress/config';
import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics';

export default defineConfig({
  builderPlugins: [
    pluginGoogleAnalytics({
      // replace this with your Google tag ID
      id: 'G-xxxxxxxxxx',
    }),
  ],
});
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.