Build Config

builderConfig

  • Type: Object

Used to customize the configurations of Modern.js Builder. For complete configurations, please refer to Modern.js Builder - API.

For example, change the output directory to doc_dist:

rspress.config.ts
export default defineConfig({
  builderConfig: {
    output: {
      distPath: {
        root: 'doc_dist',
      },
    },
  },
});

builderPlugins

  • Type: BuilderPlugin[]

Used to customize the plugins of Modern.js Builder. For example:

rspress.config.ts
import { defineConfig } from 'rspress/config';
import { builderPluginStylus } from '@rspress/builder-plugin-stylus';

export default defineConfig({
  builderPlugins: [builderPluginStylus()],
});

Default Config

If you need to see the default builderConfig, you can add the DEBUG=builder parameter when running the rspress dev or rspress build command:

DEBUG=builder rspress dev

After execution, the builder.config.js file is created in the doc_build directory, which contains the complete builderConfig.

Please refer to Modern.js Builder - Debug Mode for more information on how to debug the Builder.

markdown

  • Type: Object

Configure MDX-related compilation abilities.

markdown.remarkPlugins

  • Type: Array
  • Default: []

Configure the remark plugins. for example:

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

export default defineConfig({
  markdown: {
    remarkPlugins: [
      [
        require('remark-autolink-headings'),
        {
          behavior: 'wrap',
        },
      ],
    ],
  },
});

markdown.rehypePlugins

  • Type: Array

Configure the rehype plugin. for example:

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

export default defineConfig({
  markdown: {
    rehypePlugins: [
      [
        require('rehype-autolink-headings'),
        {
          behavior: 'wrap',
        },
      ],
    ],
  },
});
  • Type: boolean
  • Default: false

Whether to check for dead links. for example:

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

export default defineConfig({
  markdown: {
    checkDeadLinks: true,
  },
});

After enabling this config, the framework will check the links in the document based on the conventional routing table. If there is an unreachable link, the build will throw an error and exit.

markdown.experimentalMdxRs

  • Type: boolean

Whether to use the Rust version of the MDX compiler, an experimental feature. For example:

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

export default defineConfig({
  markdown: {
    experimentalMdxRs: true,
  },
});
NOTICE

The bottom layer of this function is based on the @modern/mdx-rs-binding library developed by Rspress. The performance is 5 ~ 10 times higher than the JS version of the MDX compiler, but the JS version of the plugin is not yet supported. If you need to add a custom remark or rehype plugin, it is not recommended to enable this function.

markdown.showLineNumbers

  • Type: boolean

Whether to display the line number of the code block. Defaults to false.

markdown.globalComponents

  • Type: string[]

Register component to the global scope, which will make it automatically available in every MDX file, without any import statements.For example:

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

export default defineConfig({
  markdown: {
    globalComponents: [path.join(__dirname, 'src/src/components/Alert.tsx')],
  },
});

Then you can use the Alert component in any MDX file:

test.mdx
<Alert type="info">This is a info alert</Alert>
Danger

Do not enable experimentalMdxRs when configuring globalComponents, otherwise the global components will not take effect.