rspress 1.32.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +18 -12
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -50,6 +50,15 @@ async function loadConfigFile(customConfigFile) {
50
50
  });
51
51
  return content;
52
52
  }
53
+ function resolveDocRoot(cwd, cliRoot, configRoot) {
54
+ if (cliRoot) {
55
+ return path.join(cwd, cliRoot);
56
+ }
57
+ if (configRoot) {
58
+ return path.isAbsolute(configRoot) ? configRoot : path.join(cwd, configRoot);
59
+ }
60
+ return path.join(cwd, "docs");
61
+ }
53
62
 
54
63
  // src/update.ts
55
64
  import path2 from "path";
@@ -126,12 +135,8 @@ cli.command("[root]", "start dev server").alias("dev").option("--port [port]", "
126
135
  const startDevServer = async () => {
127
136
  const { port, host } = options || {};
128
137
  const config = await loadConfigFile(options?.config);
129
- if (root) {
130
- config.root = path3.join(cwd, root);
131
- } else if (config.root && !path3.isAbsolute(config.root)) {
132
- config.root = path3.join(cwd, config.root);
133
- }
134
- const docDirectory = config.root || path3.join(cwd, root ?? "docs");
138
+ config.root = resolveDocRoot(cwd, root, config.root);
139
+ const docDirectory = config.root;
135
140
  devServer = await dev({
136
141
  appDirectory: cwd,
137
142
  docDirectory,
@@ -182,20 +187,21 @@ cli.command("build [root]").action(async (root, options) => {
182
187
  setNodeEnv("production");
183
188
  const cwd = process.cwd();
184
189
  const config = await loadConfigFile(options.config);
185
- if (root) {
186
- config.root = path3.join(cwd, root);
187
- }
190
+ config.root = resolveDocRoot(cwd, root, config.root);
191
+ const docDirectory = config.root;
188
192
  await build({
189
193
  appDirectory: cwd,
190
- docDirectory: config.root || path3.join(cwd, root ?? "docs"),
194
+ docDirectory,
191
195
  config
192
196
  });
193
197
  });
194
- cli.command("preview").alias("serve").option("--port [port]", "port number").option("--host [host]", "hostname").action(
195
- async (options) => {
198
+ cli.command("preview [root]").alias("serve").option("--port [port]", "port number").option("--host [host]", "hostname").action(
199
+ async (root, options) => {
196
200
  setNodeEnv("production");
201
+ const cwd = process.cwd();
197
202
  const { port, host } = options || {};
198
203
  const config = await loadConfigFile(options?.config);
204
+ config.root = resolveDocRoot(cwd, root, config.root);
199
205
  await serve({
200
206
  config,
201
207
  host,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rspress",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,12 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@rsbuild/core": "1.0.10",
31
+ "@rsbuild/core": "1.0.12",
32
32
  "cac": "^6.7.14",
33
33
  "chalk": "5.3.0",
34
34
  "chokidar": "^3.6.0",
35
- "@rspress/core": "1.32.0",
36
- "@rspress/shared": "1.32.0"
35
+ "@rspress/core": "1.33.0",
36
+ "@rspress/shared": "1.33.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/jest": "~29.5.13",