rspress 1.2.1 → 1.3.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.
- package/dist/index.js +56 -52
- 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").
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
const
|
78
|
-
|
79
|
-
config
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
103
|
-
|
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
|
-
|
107
|
-
|
109
|
+
path2.relative(cwd, filepath)
|
110
|
+
)}, dev server will restart...
|
108
111
|
`
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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.
|
3
|
+
"version": "1.3.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
|
-
"@modern-js/node-bundle-require": "2.
|
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/
|
36
|
-
"@rspress/
|
35
|
+
"@rspress/shared": "1.3.0",
|
36
|
+
"@rspress/core": "1.3.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@types/jest": "~29.2.4",
|