You can create a Rspress project using the create-rspress
cli:
npm create rspress@latest
Input the project directory name, and then the cli will create the project for you.
First, you can create a new directory with the following command:
mkdir rspress-app && cd rspress-app
Execute npm init -y
to initialize a project. You can install Rspress using npm, yarn or pnpm:
npm install rspress typescript ts-node -D
Then create the file with the following command
mkdir docs && echo '# Hello World' > docs/index.md
Add the following script to package.json
:
{
"scripts": {
"dev": "rspress dev",
"build": "rspress build",
"preview": "rspress preview"
}
}
Then initialize a configuration file rspress.config.ts
:
import { defineConfig } from 'rspress/config';
import path from 'path';
export default defineConfig({
root: path.join(__dirname, 'docs'),
});
And then create tsconfig.json
, add the following config:
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx"
}
}
Start the local development service with the following command:
npm run dev
Build the production bundle with the following command :
npm run build
By default, Rspress will set doc_build
as the output directory.
Start the local preview service with the following command:
npm run preview