slidev-workspace 0.7.0 → 0.7.2
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/cli.js +20 -15
- package/dist/plugin-slides.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -172,7 +172,7 @@ async function startAllSlidesDevServer(workspaceCwd) {
|
|
|
172
172
|
], {
|
|
173
173
|
cwd: slideDir,
|
|
174
174
|
stdio: [
|
|
175
|
-
"
|
|
175
|
+
"pipe",
|
|
176
176
|
"pipe",
|
|
177
177
|
"pipe"
|
|
178
178
|
],
|
|
@@ -339,6 +339,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
339
339
|
const __dirname = dirname(__filename);
|
|
340
340
|
const args = process.argv.slice(2);
|
|
341
341
|
const command = args[0];
|
|
342
|
+
const dirsArg = args[1];
|
|
342
343
|
const packageRoot = join(__dirname, "..");
|
|
343
344
|
function createViteConfig() {
|
|
344
345
|
const workspaceCwd = process.env.SLIDEV_WORKSPACE_CWD || process.cwd();
|
|
@@ -359,17 +360,17 @@ function createViteConfig() {
|
|
|
359
360
|
}
|
|
360
361
|
};
|
|
361
362
|
}
|
|
362
|
-
async function
|
|
363
|
+
async function buildSlides(names) {
|
|
363
364
|
const workspaceCwd = process.env.SLIDEV_WORKSPACE_CWD || process.cwd();
|
|
364
365
|
const config = loadConfig(workspaceCwd);
|
|
365
366
|
const slidesDirs = resolveSlidesDirs(config, workspaceCwd);
|
|
366
|
-
console.log("🔨 Building all slides...");
|
|
367
|
+
console.log(names ? `🔨 Building slides: ${names.join(", ")}...` : "🔨 Building all slides...");
|
|
367
368
|
for (const slidesDir of slidesDirs) {
|
|
368
369
|
if (!existsSync(slidesDir)) {
|
|
369
370
|
console.warn(`⚠️ Slides directory not found: ${slidesDir}`);
|
|
370
371
|
continue;
|
|
371
372
|
}
|
|
372
|
-
const slides = readdirSync(slidesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
373
|
+
const slides = names ? names.filter((name) => existsSync(join(slidesDir, name))) : readdirSync(slidesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
373
374
|
for (const slideName of slides) {
|
|
374
375
|
const slideDir = join(slidesDir, slideName);
|
|
375
376
|
const packageJsonPath = join(slideDir, "package.json");
|
|
@@ -435,7 +436,7 @@ async function exportOgImages() {
|
|
|
435
436
|
process.exit(1);
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
|
-
async function copySlidesToOutputDir() {
|
|
439
|
+
async function copySlidesToOutputDir(names) {
|
|
439
440
|
const workspaceCwd = process.env.SLIDEV_WORKSPACE_CWD || process.cwd();
|
|
440
441
|
const config = loadConfig(workspaceCwd);
|
|
441
442
|
const slidesDirs = resolveSlidesDirs(config, workspaceCwd);
|
|
@@ -444,7 +445,7 @@ async function copySlidesToOutputDir() {
|
|
|
444
445
|
if (!existsSync(deployDir)) mkdirSync(deployDir, { recursive: true });
|
|
445
446
|
for (const slidesDir of slidesDirs) {
|
|
446
447
|
if (!existsSync(slidesDir)) continue;
|
|
447
|
-
const slides = readdirSync(slidesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
448
|
+
const slides = names ? names.filter((name) => existsSync(join(slidesDir, name))) : readdirSync(slidesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
448
449
|
for (const slideName of slides) {
|
|
449
450
|
const slideDistDir = join(slidesDir, slideName, "dist");
|
|
450
451
|
const targetDir = join(deployDir, slideName);
|
|
@@ -456,13 +457,13 @@ async function copySlidesToOutputDir() {
|
|
|
456
457
|
}
|
|
457
458
|
console.log(`✅ All slide assets copied into ${deployDir}!`);
|
|
458
459
|
}
|
|
459
|
-
async function runViteBuild() {
|
|
460
|
+
async function runViteBuild(names) {
|
|
460
461
|
try {
|
|
461
|
-
await
|
|
462
|
+
await buildSlides(names);
|
|
462
463
|
console.log("📦 Building Slidev Workspace for production...");
|
|
463
464
|
const config = createViteConfig();
|
|
464
465
|
await build(config);
|
|
465
|
-
await copySlidesToOutputDir();
|
|
466
|
+
await copySlidesToOutputDir(names);
|
|
466
467
|
console.log("✅ Build completed successfully!");
|
|
467
468
|
} catch (error) {
|
|
468
469
|
console.error("❌ Build failed:", error);
|
|
@@ -489,14 +490,16 @@ Usage:
|
|
|
489
490
|
slidev-workspace <command> [options]
|
|
490
491
|
|
|
491
492
|
Commands:
|
|
492
|
-
dev
|
|
493
|
-
build
|
|
494
|
-
|
|
495
|
-
|
|
493
|
+
dev Start the development server
|
|
494
|
+
build [names] Build the project for production
|
|
495
|
+
[names]: Optional comma-separated list of slide folder names to build
|
|
496
|
+
export-og Export OG images for all slides
|
|
497
|
+
help Show this help message
|
|
496
498
|
|
|
497
499
|
Examples:
|
|
498
500
|
slidev-workspace dev # Start development server
|
|
499
501
|
slidev-workspace build # Build all slides and preview app
|
|
502
|
+
slidev-workspace build slide1,slide2 # Build only specific slides by name
|
|
500
503
|
slidev-workspace export-og # Export OG images for all slides
|
|
501
504
|
|
|
502
505
|
Configuration:
|
|
@@ -512,10 +515,12 @@ async function main() {
|
|
|
512
515
|
process.env.SLIDEV_WORKSPACE_CWD = process.cwd();
|
|
513
516
|
await runVitePreview();
|
|
514
517
|
break;
|
|
515
|
-
case "build":
|
|
518
|
+
case "build": {
|
|
516
519
|
process.env.SLIDEV_WORKSPACE_CWD = process.cwd();
|
|
517
|
-
|
|
520
|
+
const names = dirsArg ? dirsArg.split(",").map((d) => d.trim()) : void 0;
|
|
521
|
+
await runViteBuild(names);
|
|
518
522
|
break;
|
|
523
|
+
}
|
|
519
524
|
case "export-og":
|
|
520
525
|
process.env.SLIDEV_WORKSPACE_CWD = process.cwd();
|
|
521
526
|
await exportOgImages();
|
package/dist/plugin-slides.js
CHANGED