create-spark-html-app 0.3.3 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-spark-html-app",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Scaffold a Vite + spark-html app with a live reactive welcome screen.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,13 +13,28 @@ npm run dev
13
13
  Open the dev server and edit `public/components/welcome.html`. Save, and the
14
14
  page reloads instantly.
15
15
 
16
- ## Build
16
+ ## Build (SEO-ready)
17
17
 
18
18
  ```bash
19
19
  npm run build # static output → dist/, serve anywhere
20
20
  npm run preview # preview the production build locally
21
21
  ```
22
22
 
23
+ `npm run build` is **SEO-friendly out of the box**: the `spark-prerender`
24
+ Vite plugin runs your app at build time and writes fully-rendered HTML into
25
+ `dist/` — so crawlers and AI tools read real content (headings, text, links),
26
+ not empty placeholders. The browser still hydrates over it for full
27
+ interactivity. Set page metadata as plain component state:
28
+
29
+ ```html
30
+ <script>
31
+ let pageTitle = 'My App — does a thing';
32
+ let pageDescription = 'A short, crawlable description of the page.';
33
+ </script>
34
+ ```
35
+
36
+ Don't need SEO? Remove the `prerender(...)` plugin from `vite.config.js`.
37
+
23
38
  ## How it's wired
24
39
 
25
40
  ```
@@ -29,7 +44,7 @@ npm run preview # preview the production build locally
29
44
  ├── public/components/ ← your components (plain .html files)
30
45
  │ ├── app.html ← theme + shell
31
46
  │ └── welcome.html ← the live reactive welcome screen
32
- └── vite.config.js ← spark-html/vite plugin
47
+ └── vite.config.js ← spark-html/vite + spark-prerender/vite (SEO)
33
48
  ```
34
49
 
35
50
  A component is a `.html` file with optional `<script>` and `<style>`. Top-level
@@ -12,6 +12,7 @@
12
12
  "spark-html": "latest"
13
13
  },
14
14
  "devDependencies": {
15
+ "spark-prerender": "latest",
15
16
  "vite": "^5.0.0"
16
17
  }
17
18
  }
@@ -1,10 +1,19 @@
1
1
  import { defineConfig } from 'vite';
2
2
  import spark from 'spark-html/vite';
3
+ import prerender from 'spark-prerender/vite';
3
4
 
4
5
  // Spark needs no build step — Vite is just a convenient dev server and
5
6
  // bundler. The plugin serves component fragments raw and full-reloads
6
7
  // when one changes. Components live in public/ so they ship verbatim to
7
8
  // the production build too.
9
+ //
10
+ // `prerender()` makes `npm run build` SEO-friendly: it runs your app at
11
+ // build time and writes fully-rendered HTML into dist/ (crawlers and AI
12
+ // tools read real content; the browser still hydrates over it). Remove it
13
+ // if you don't need SEO. List every page you ship in `pages`.
8
14
  export default defineConfig({
9
- plugins: [spark()],
15
+ plugins: [
16
+ spark(),
17
+ prerender({ pages: ['index.html'] }),
18
+ ],
10
19
  });