svelte-bundle 0.2.0-beta.1 → 0.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/ReadMe.md +50 -90
- package/package.json +8 -2
package/ReadMe.md
CHANGED
|
@@ -1,36 +1,18 @@
|
|
|
1
|
-
>
|
|
1
|
+
> **Early release** — functional but not yet battle-tested across all use-cases.
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
```bash
|
|
7
|
-
svelte-bundle create my-app
|
|
8
|
-
cd my-app
|
|
9
|
-
svelte-bundle build
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
### Full Documentation: [https://github.com/uhteddy/svelte-bundle/wiki](https://github.com/uhteddy/svelte-bundle/wiki)
|
|
5
|
+
# svelte-bundle
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
Scaffold a Svelte 5 + Vite project and bundle it into a **single self-contained `.html` file** — CSS and JS fully inlined, no web server required.
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
Built for environments that only accept plain HTML: legacy CMS platforms or anywhere you need real reactivity without a build server.
|
|
17
10
|
|
|
18
|
-
|
|
11
|
+
> **Not a SvelteKit tool.** This scaffolds a standalone Svelte 5 app and outputs one `.html` file.
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
⚠️ **Note**: This tool is **NOT** made to function with SvelteKit natively. It scaffolds a standalone Svelte 5 app (not a SvelteKit project) and outputs a single `.html` file.
|
|
23
|
-
|
|
24
|
-
## Inspiration
|
|
25
|
-
This tool was inspired by the need I had when it came to updating the CMS for a company I worked for. They were looking for more custom content on their website which used an outdated CMS. Pages were only able to include HTML, CSS, and JS.
|
|
26
|
-
|
|
27
|
-
Pure HTML, CSS, and JS can be granular and more importantly, lacks the reactivity that Svelte has. Meaning, to develop certain features I had to focus a lot more on the "what to do" when data changes, rather than Svelte handling that for me.
|
|
28
|
-
|
|
29
|
-
So, I searched for tools around that could be of assistance. I found [figsvelte](https://github.com/thomas-lowry/figsvelte) which was of so much help in the underlying understanding of what to do. But, it did not accomplish all I was looking for. I needed a solution that didn't just generate an HTML file with JS that hydrated the page. Through a lot of tinkering I was finally able to get the system to work.
|
|
30
|
-
|
|
31
|
-
I noticed through a lot of Google searches I wasn't the only one looking for a solution like this, yet I was unable to find one that addressed everything I was looking for. So, for this reason I built svelte-bundle to take care of this in a much more simplistic and CLI-driven way.
|
|
13
|
+
---
|
|
32
14
|
|
|
33
|
-
##
|
|
15
|
+
## Install
|
|
34
16
|
|
|
35
17
|
```bash
|
|
36
18
|
npm install -g svelte-bundle
|
|
@@ -38,49 +20,57 @@ npm install -g svelte-bundle
|
|
|
38
20
|
bun add -g svelte-bundle
|
|
39
21
|
```
|
|
40
22
|
|
|
41
|
-
`sb` is available
|
|
23
|
+
Short alias `sb` is also available.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Quickstart
|
|
42
28
|
|
|
43
29
|
```bash
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
svelte-bundle create my-app
|
|
31
|
+
cd my-app
|
|
32
|
+
npm run dev # develop with hot reload
|
|
33
|
+
svelte-bundle build # → dist/index.html
|
|
46
34
|
```
|
|
47
35
|
|
|
48
36
|
---
|
|
49
37
|
|
|
50
|
-
##
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `svelte-bundle create [name]`
|
|
51
41
|
|
|
52
|
-
Scaffolds a new
|
|
42
|
+
Scaffolds a new project with Svelte 5, Vite, and TypeScript — ready to run.
|
|
53
43
|
|
|
54
44
|
```bash
|
|
55
45
|
svelte-bundle create my-app
|
|
56
46
|
```
|
|
57
47
|
|
|
58
|
-
Interactive prompts
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
48
|
+
Interactive prompts let you choose a package manager and optional features. You can also skip prompts with flags:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
svelte-bundle create my-app --pm bun --no-git
|
|
52
|
+
```
|
|
63
53
|
|
|
64
54
|
| Flag | Description |
|
|
65
55
|
|---|---|
|
|
66
|
-
|
|
|
67
|
-
| `--pm` |
|
|
56
|
+
| `-t, --template` | Template to use (default: `default`) |
|
|
57
|
+
| `--pm` | Package manager: `bun`, `npm`, `pnpm`, `yarn` |
|
|
68
58
|
| `--no-install` | Skip dependency installation |
|
|
69
59
|
| `--no-git` | Skip git initialization |
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
**Optional features** (selected during prompts):
|
|
62
|
+
- **Tailwind CSS** — `@tailwindcss/vite` v4, zero config
|
|
63
|
+
- **ESLint** — with Svelte plugin
|
|
64
|
+
- **Prettier** — with Svelte plugin
|
|
65
|
+
- **Vitest** — unit testing setup
|
|
76
66
|
|
|
67
|
+
**Output structure:**
|
|
77
68
|
```
|
|
78
69
|
my-app/
|
|
79
70
|
├── src/
|
|
80
71
|
│ ├── App.svelte ← root component
|
|
81
72
|
│ ├── main.ts ← entry point
|
|
82
|
-
│ └── lib/
|
|
83
|
-
│ └── index.ts ← library re-export entry
|
|
73
|
+
│ └── lib/index.ts
|
|
84
74
|
├── public/
|
|
85
75
|
├── index.html
|
|
86
76
|
├── vite.config.ts
|
|
@@ -88,71 +78,41 @@ my-app/
|
|
|
88
78
|
└── package.json
|
|
89
79
|
```
|
|
90
80
|
|
|
91
|
-
### Dev server
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
cd my-app
|
|
95
|
-
npm run dev
|
|
96
|
-
```
|
|
97
|
-
|
|
98
81
|
---
|
|
99
82
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Builds the project into a **single self-contained `dist/index.html`** with all CSS and JavaScript inlined — no separate asset files, no web server needed.
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
cd my-app
|
|
106
|
-
svelte-bundle build
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
| Flag | Default | Description |
|
|
110
|
-
|---|---|---|
|
|
111
|
-
| `--hydrate` | `false` | Pre-render with Svelte SSR for SEO-friendly output |
|
|
112
|
-
| `--entry` | `src/App.svelte` | Root component for SSR pre-rendering |
|
|
113
|
-
| `--outfile` | `dist/index.html` | Output file path |
|
|
114
|
-
| `--mode / -m` | `production` | Vite build mode |
|
|
83
|
+
### `svelte-bundle build`
|
|
115
84
|
|
|
116
|
-
|
|
85
|
+
Compiles the project and inlines everything into a single `dist/index.html`.
|
|
117
86
|
|
|
118
87
|
```bash
|
|
119
88
|
svelte-bundle build
|
|
120
89
|
```
|
|
121
90
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### Hydrated build (SSR)
|
|
91
|
+
Add `--hydrate` to pre-render with SSR — useful for SEO, fast LCP, or CMS environments that crawl content:
|
|
125
92
|
|
|
126
93
|
```bash
|
|
127
94
|
svelte-bundle build --hydrate
|
|
128
95
|
```
|
|
129
96
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
- **SEO** — search engine crawlers see actual content immediately
|
|
133
|
-
- **LCP** — Largest Contentful Paint is not blocked by JS execution
|
|
134
|
-
- **CMS / embedded use** — a fully pre-rendered, static single file
|
|
97
|
+
With `--hydrate`, the root component is server-rendered first so real HTML content exists before JavaScript runs. The client JS automatically calls `hydrate()` or `mount()` depending on what it finds — no extra config needed.
|
|
135
98
|
|
|
136
|
-
|
|
99
|
+
| Flag | Default | Description |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `--hydrate` | `false` | Pre-render with Svelte SSR |
|
|
102
|
+
| `--entry` | `src/App.svelte` | Root component for SSR |
|
|
103
|
+
| `--outfile` | `dist/index.html` | Output path |
|
|
104
|
+
| `-m, --mode` | `production` | Vite build mode |
|
|
137
105
|
|
|
138
|
-
|
|
106
|
+
**How the build works:**
|
|
107
|
+
1. `vite build` compiles and minifies the Svelte app
|
|
108
|
+
2. Every `<link rel="stylesheet">` is replaced with an inline `<style>` block
|
|
109
|
+
3. Every `<script src="...">` is replaced with an inline `<script type="module">` block
|
|
110
|
+
4. *(with `--hydrate`)* A Vite SSR build pre-renders the component and injects the HTML into `<div id="app">`
|
|
139
111
|
|
|
140
|
-
|
|
141
|
-
2. **Inline** — every `<link rel="stylesheet">` becomes an inline `<style>` block; every `<script src="...">` becomes an inline `<script type="module">` block
|
|
142
|
-
3. **SSR** *(with `--hydrate` only)* — a temporary Vite SSR build server-renders the component; the HTML is injected into `<div id="app">` before inlining; all temp files are cleaned up automatically
|
|
112
|
+
The result is one `.html` file you can open directly in a browser or drop into any system.
|
|
143
113
|
|
|
144
114
|
---
|
|
145
115
|
|
|
146
|
-
## Features
|
|
147
|
-
- [x] Scaffold a Svelte 5 + Vite project with a single command
|
|
148
|
-
- [x] Outputs a single `.html` file ready for deployment anywhere
|
|
149
|
-
- [x] All CSS and JS fully inlined — zero external dependencies at runtime
|
|
150
|
-
- [x] SSR hydration support for SEO-safe output
|
|
151
|
-
- [x] Tailwind CSS support out of the box (selected during `create`)
|
|
152
|
-
- [x] Optional ESLint, Prettier, and Vitest setup
|
|
153
|
-
- [x] TypeScript everywhere, strict mode enforced
|
|
154
|
-
- [x] Works with any Vite plugin ecosystem
|
|
155
|
-
|
|
156
116
|
## Requirements
|
|
157
117
|
|
|
158
118
|
- Node.js 18+ or Bun 1.0+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-bundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A powerful CLI for scaffolding and bundling Svelte components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"build": "bun build src/cli.ts --outfile dist/cli.js --target node --format esm",
|
|
19
19
|
"dev": "bun run src/cli.ts",
|
|
20
20
|
"test": "bun test",
|
|
21
|
-
"type-check": "tsc --noEmit"
|
|
21
|
+
"type-check": "tsc --noEmit",
|
|
22
|
+
"release": "release-it",
|
|
23
|
+
"prepare": "husky"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"@clack/prompts": "^0.9.1",
|
|
@@ -26,7 +28,11 @@
|
|
|
26
28
|
"picocolors": "^1.1.1"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
31
|
+
"@commitlint/cli": "^20.4.3",
|
|
32
|
+
"@commitlint/config-conventional": "^20.4.3",
|
|
33
|
+
"@release-it/conventional-changelog": "^10.0.5",
|
|
29
34
|
"@types/bun": "latest",
|
|
35
|
+
"husky": "^9.1.7",
|
|
30
36
|
"release-it": "^19.2.4",
|
|
31
37
|
"typescript": "^5"
|
|
32
38
|
}
|