@berlysia/vertical-writing-slide-system 0.0.19 → 0.0.20

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/cli.js +14 -46
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -1,61 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  // @ts-check
3
3
 
4
- import { writeFile, access } from "node:fs/promises";
5
4
  import { resolve } from "node:path";
6
5
  import { parseArgs } from "node:util";
7
6
  import { build, createServer } from "vite";
8
7
 
9
- async function ensureIndexHtml() {
10
- const indexHtmlPath = resolve(process.cwd(), "index.html");
11
- try {
12
- await access(indexHtmlPath);
13
- // index.html already exists
14
- return;
15
- } catch {
16
- // index.html doesn't exist, create it
17
- // Use absolute paths from the library location for external projects
18
- const libPath = import.meta.dirname;
19
- const libSrcPath = resolve(libPath, "src");
20
-
21
- // Convert to relative paths from project root that Vite can resolve
22
- const relativeSrcPath = `/@fs${libSrcPath}`;
23
-
24
- const indexHtmlContent = `<!doctype html>
25
- <html lang="ja">
26
- <head>
27
- <meta charset="UTF-8" />
28
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
29
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
30
- <title>Vertical Writing Slides</title>
31
- <link rel="preconnect" href="https://fonts.googleapis.com">
32
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
33
- <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
34
- <link rel="stylesheet" href="${relativeSrcPath}/index.css" />
35
- <link rel="stylesheet" media="screen" href="${relativeSrcPath}/screen.css" />
36
- <link rel="stylesheet" media="print" href="${relativeSrcPath}/print.css" />
37
- </head>
38
- <body>
39
- <div id="root"></div>
40
- <script type="module" src="${relativeSrcPath}/main.tsx"></script>
41
- </body>
42
- </html>`;
43
-
44
- await writeFile(indexHtmlPath, indexHtmlContent);
45
- console.log("Generated index.html for external project");
46
- }
47
- }
48
-
49
8
  async function runDev() {
50
9
  try {
51
10
  const libPath = import.meta.dirname;
52
11
  const projectPath = process.cwd();
53
12
 
54
- // Ensure index.html exists for external projects
55
- await ensureIndexHtml();
13
+ // Set environment variables for external project
14
+ if (!process.env.SLIDES_DIR) {
15
+ process.env.SLIDES_DIR = resolve(projectPath, "./slides");
16
+ }
56
17
 
57
18
  const server = await createServer({
58
- root: projectPath, // Use project as root for proper file watching
19
+ root: libPath, // Use library as root to serve its index.html
59
20
  configFile: resolve(libPath, "vite.config.ts"),
60
21
  server: {
61
22
  fs: {
@@ -98,13 +59,20 @@ async function runBuildAll() {
98
59
 
99
60
  async function runBuild() {
100
61
  try {
62
+ const projectPath = process.cwd();
63
+
64
+ // Set environment variables for external project
65
+ if (!process.env.SLIDES_DIR) {
66
+ process.env.SLIDES_DIR = resolve(projectPath, "./slides");
67
+ }
68
+
101
69
  await build({
102
- root: process.cwd(),
70
+ root: import.meta.dirname, // Use library as root like dev mode
103
71
  configFile: resolve(import.meta.dirname, "vite.config.ts"),
104
72
  build: {
105
73
  outDir: resolve(process.cwd(), "pages"),
106
74
  rollupOptions: {
107
- input: resolve(import.meta.dirname, "src/main.tsx"),
75
+ input: resolve(import.meta.dirname, "index.html"),
108
76
  output: {
109
77
  assetFileNames: "assets/[name]-[hash][extname]",
110
78
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berlysia/vertical-writing-slide-system",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vertical-slides": "./cli.js"