@slidev/cli 51.6.0 → 51.7.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/build-B6Mgy-Y-.js +62 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +518 -594
- package/dist/export-D1Zqc-n1.js +433 -0
- package/dist/index.d.ts +12 -7
- package/dist/index.js +5 -17
- package/dist/resolver-BShaA6qw.js +155 -0
- package/dist/serve-Cg-fgcfD.js +14 -0
- package/dist/shared-bpaLqEdy.js +2475 -0
- package/package.json +26 -26
- package/dist/build-Z7GTSSXD.js +0 -77
- package/dist/chunk-BCA62OS7.js +0 -29
- package/dist/chunk-TJFRPB4N.js +0 -190
- package/dist/chunk-Y2DHOFI5.js +0 -2761
- package/dist/export-5TR5BGLG.js +0 -520
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { resolveViteConfigs } from "./shared-bpaLqEdy.js";
|
|
2
|
+
import "./resolver-BShaA6qw.js";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { build as build$1 } from "vite";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import http from "node:http";
|
|
8
|
+
import connect from "connect";
|
|
9
|
+
import sirv from "sirv";
|
|
10
|
+
|
|
11
|
+
//#region node/commands/build.ts
|
|
12
|
+
async function build(options, viteConfig = {}, args) {
|
|
13
|
+
const indexPath = resolve(options.userRoot, "index.html");
|
|
14
|
+
let originalIndexHTML;
|
|
15
|
+
if (existsSync(indexPath)) originalIndexHTML = await fs.readFile(indexPath, "utf-8");
|
|
16
|
+
await fs.writeFile(indexPath, options.utils.indexHtml, "utf-8");
|
|
17
|
+
let config = void 0;
|
|
18
|
+
try {
|
|
19
|
+
const inlineConfig = await resolveViteConfigs(options, {
|
|
20
|
+
plugins: [{
|
|
21
|
+
name: "resolve-config",
|
|
22
|
+
configResolved(_config) {
|
|
23
|
+
config = _config;
|
|
24
|
+
}
|
|
25
|
+
}],
|
|
26
|
+
build: { chunkSizeWarningLimit: 2e3 }
|
|
27
|
+
}, viteConfig, "build");
|
|
28
|
+
await build$1(inlineConfig);
|
|
29
|
+
} finally {
|
|
30
|
+
if (originalIndexHTML != null) await fs.writeFile(indexPath, originalIndexHTML, "utf-8");
|
|
31
|
+
else await fs.unlink(indexPath);
|
|
32
|
+
}
|
|
33
|
+
const outDir = resolve(options.userRoot, config.build.outDir);
|
|
34
|
+
await fs.copyFile(resolve(outDir, "index.html"), resolve(outDir, "404.html"));
|
|
35
|
+
const redirectsPath = resolve(outDir, "_redirects");
|
|
36
|
+
if (!existsSync(redirectsPath)) await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200\n`, "utf-8");
|
|
37
|
+
if ([
|
|
38
|
+
true,
|
|
39
|
+
"true",
|
|
40
|
+
"auto"
|
|
41
|
+
].includes(options.data.config.download)) {
|
|
42
|
+
const { exportSlides, getExportOptions } = await import("./export-D1Zqc-n1.js");
|
|
43
|
+
const port = 12445;
|
|
44
|
+
const app = connect();
|
|
45
|
+
const server = http.createServer(app);
|
|
46
|
+
app.use(config.base, sirv(outDir, {
|
|
47
|
+
etag: true,
|
|
48
|
+
single: true,
|
|
49
|
+
dev: true
|
|
50
|
+
}));
|
|
51
|
+
server.listen(port);
|
|
52
|
+
await exportSlides({
|
|
53
|
+
port,
|
|
54
|
+
base: config.base,
|
|
55
|
+
...getExportOptions(args, options, join(outDir, "slidev-exported.pdf"))
|
|
56
|
+
});
|
|
57
|
+
server.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { build };
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export { };
|