rspress 1.2.1 → 1.3.1

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 +56 -52
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -66,62 +66,66 @@ var setNodeEnv = (env) => {
66
66
  process.env.NODE_ENV = env;
67
67
  };
68
68
  cli.option("--config [config]", "Specify the path to the config file");
69
- cli.command("[root]", "start dev server").alias("dev").action(async (root, options) => {
70
- setNodeEnv("development");
71
- let isRestarting = false;
72
- const cwd = process.cwd();
73
- let docDirectory;
74
- let cliWatcher;
75
- let devServer;
76
- const startDevServer = async () => {
77
- const config = await loadConfigFile(options.config);
78
- if (config.root && !path2.isAbsolute(config.root)) {
79
- config.root = path2.join(cwd, config.root);
80
- }
81
- if (root) {
82
- config.root = path2.join(cwd, root);
83
- }
84
- docDirectory = config.root || path2.join(cwd, root ?? "docs");
85
- devServer = await dev({
86
- appDirectory: cwd,
87
- docDirectory,
88
- config
89
- });
90
- cliWatcher = chokidar.watch(
91
- [`${cwd}/**/{${CONFIG_FILES.join(",")}}`, docDirectory],
92
- {
93
- ignoreInitial: true,
94
- ignored: ["**/node_modules/**", "**/.git/**", "**/.DS_Store/**"]
69
+ cli.command("[root]", "start dev server").alias("dev").option("--port [port]", "port number").option("--host [host]", "hostname").action(
70
+ async (root, options) => {
71
+ setNodeEnv("development");
72
+ let isRestarting = false;
73
+ const cwd = process.cwd();
74
+ let docDirectory;
75
+ let cliWatcher;
76
+ let devServer;
77
+ const startDevServer = async () => {
78
+ const { port, host } = options || {};
79
+ const config = await loadConfigFile(options?.config);
80
+ if (config.root && !path2.isAbsolute(config.root)) {
81
+ config.root = path2.join(cwd, config.root);
82
+ }
83
+ if (root) {
84
+ config.root = path2.join(cwd, root);
95
85
  }
96
- );
97
- cliWatcher.on("all", async (eventName, filepath) => {
98
- if (eventName === "add" || eventName === "unlink" || eventName === "change" && CONFIG_FILES.includes(path2.basename(filepath))) {
99
- if (isRestarting) {
100
- return;
86
+ docDirectory = config.root || path2.join(cwd, root ?? "docs");
87
+ devServer = await dev({
88
+ appDirectory: cwd,
89
+ docDirectory,
90
+ config,
91
+ extraBuilderConfig: { dev: { port, host } }
92
+ });
93
+ cliWatcher = chokidar.watch(
94
+ [`${cwd}/**/{${CONFIG_FILES.join(",")}}`, docDirectory],
95
+ {
96
+ ignoreInitial: true,
97
+ ignored: ["**/node_modules/**", "**/.git/**", "**/.DS_Store/**"]
101
98
  }
102
- isRestarting = true;
103
- console.log(
104
- `
99
+ );
100
+ cliWatcher.on("all", async (eventName, filepath) => {
101
+ if (eventName === "add" || eventName === "unlink" || eventName === "change" && CONFIG_FILES.includes(path2.basename(filepath))) {
102
+ if (isRestarting) {
103
+ return;
104
+ }
105
+ isRestarting = true;
106
+ console.log(
107
+ `
105
108
  ✨ ${eventName} ${chalk.green(
106
- path2.relative(cwd, filepath)
107
- )}, dev server will restart...
109
+ path2.relative(cwd, filepath)
110
+ )}, dev server will restart...
108
111
  `
109
- );
110
- await devServer.close();
111
- await cliWatcher.close();
112
- await startDevServer();
113
- isRestarting = false;
114
- }
115
- });
116
- };
117
- await startDevServer();
118
- const exitProcess = async () => {
119
- await cliWatcher.close();
120
- await devServer.close();
121
- };
122
- process.on("SIGINT", exitProcess);
123
- process.on("SIGTERM", exitProcess);
124
- });
112
+ );
113
+ await devServer.close();
114
+ await cliWatcher.close();
115
+ await startDevServer();
116
+ isRestarting = false;
117
+ }
118
+ });
119
+ };
120
+ await startDevServer();
121
+ const exitProcess = async () => {
122
+ await cliWatcher.close();
123
+ await devServer.close();
124
+ };
125
+ process.on("SIGINT", exitProcess);
126
+ process.on("SIGTERM", exitProcess);
127
+ }
128
+ );
125
129
  cli.command("build [root]").option("-c --config <config>", "specify config file").action(async (root, options) => {
126
130
  setNodeEnv("production");
127
131
  const cwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rspress",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
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
- "@modern-js/node-bundle-require": "2.38.0",
31
+ "@modern-js/node-bundle-require": "2.39.0",
32
32
  "cac": "^6.7.14",
33
33
  "chokidar": "^3.5.3",
34
34
  "chalk": "5.3.0",
35
- "@rspress/core": "1.2.1",
36
- "@rspress/shared": "1.2.1"
35
+ "@rspress/core": "1.3.1",
36
+ "@rspress/shared": "1.3.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/jest": "~29.2.4",