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
:
export default defineConfig({
builderConfig: {
output: {
distPath: {
root: 'doc_dist',
},
},
},
});
BuilderPlugin[]
Used to customize the plugins of Modern.js Builder. For example:
import { defineConfig } from 'rspress/config';
import { builderPluginStylus } from '@rspress/builder-plugin-stylus';
export default defineConfig({
builderPlugins: [builderPluginStylus()],
});
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.
Object
Configure MDX-related compilation abilities.
Array
[]
Configure the remark plugins. for example:
import { defineConfig } from 'rspress/config';
export default defineConfig({
markdown: {
remarkPlugins: [
[
require('remark-autolink-headings'),
{
behavior: 'wrap',
},
],
],
},
});
Array
Configure the rehype plugin. for example:
import { defineConfig } from 'rspress/config';
export default defineConfig({
markdown: {
rehypePlugins: [
[
require('rehype-autolink-headings'),
{
behavior: 'wrap',
},
],
],
},
});
boolean
false
Whether to check for dead links. for example:
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.
boolean
Whether to use the Rust version of the MDX compiler, an experimental feature. For example:
import { defineConfig } from 'rspress/config';
export default defineConfig({
markdown: {
experimentalMdxRs: true,
},
});
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.
boolean
Whether to display the line number of the code block. Defaults to false
.
string[]
Register component to the global scope, which will make it automatically available in every MDX file, without any import statements.For example:
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:
<Alert type="info">This is a info alert</Alert>
Do not enable experimentalMdxRs
when configuring globalComponents
, otherwise the global components will not take effect.