svelte-bundle 0.1.0 → 0.2.0-beta.1
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 +137 -16
- package/dist/cli.js +3598 -0
- package/package.json +18 -53
- package/templates/default/_gitignore +19 -0
- package/templates/default/_package.json +18 -0
- package/templates/default/_tsconfig.app.json +25 -0
- package/templates/default/_tsconfig.json +7 -0
- package/templates/default/_tsconfig.node.json +17 -0
- package/templates/default/_vite.config.ts +11 -0
- package/templates/default/index.html +13 -0
- package/templates/default/public/.gitkeep +0 -0
- package/templates/default/src/App.svelte +41 -0
- package/templates/default/src/lib/index.ts +3 -0
- package/templates/default/src/main.ts +13 -0
- package/bundle.js +0 -330
- package/cli.js +0 -226
package/ReadMe.md
CHANGED
|
@@ -3,36 +3,157 @@
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
|
-
This tool can be used with `npx`:
|
|
7
6
|
```bash
|
|
8
|
-
|
|
7
|
+
svelte-bundle create my-app
|
|
8
|
+
cd my-app
|
|
9
|
+
svelte-bundle build
|
|
9
10
|
```
|
|
11
|
+
|
|
10
12
|
### Full Documentation: [https://github.com/uhteddy/svelte-bundle/wiki](https://github.com/uhteddy/svelte-bundle/wiki)
|
|
11
13
|
|
|
12
14
|
# Svelte Bundle CLI
|
|
13
15
|
|
|
14
|
-
**Svelte Bundle CLI** is a
|
|
16
|
+
**Svelte Bundle CLI** is a command-line tool that scaffolds a Svelte 5 + Vite project and bundles it into a single self-contained `.html` file. The goal of this tool is to make it easy to develop with Svelte and deploy anywhere — particularly for cases where everything needs to be contained in a single file.
|
|
15
17
|
|
|
16
|
-
Just note, the purpose of this tool is **NOT** to bundle an entire Svelte app
|
|
18
|
+
Just note, the purpose of this tool is **NOT** to bundle an entire large-scale Svelte app. The purpose is to expand the capabilities of Svelte to work on systems like certain Content Management Systems (CMS) that only allow HTML, CSS, and JS. It was also built with SSR hydration support so the generated file is SEO-safe, with necessary elements already pre-rendered.
|
|
17
19
|
|
|
18
|
-
Utilizing this you will be able to develop a page with the joy of
|
|
20
|
+
Utilizing this you will be able to develop a page with the joy of Svelte — components, reactivity, TypeScript, Tailwind — and output a single `.html` file you can drop anywhere.
|
|
19
21
|
|
|
20
|
-
⚠️ **Note**: This tool is **NOT** made to function with SvelteKit natively
|
|
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.
|
|
21
23
|
|
|
22
24
|
## Inspiration
|
|
23
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.
|
|
24
26
|
|
|
25
|
-
Pure HTML, CSS, and JS can be
|
|
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.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install -g svelte-bundle
|
|
37
|
+
# or
|
|
38
|
+
bun add -g svelte-bundle
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`sb` is available as a short alias:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
sb create my-app
|
|
45
|
+
sb build --hydrate
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## `svelte-bundle create`
|
|
51
|
+
|
|
52
|
+
Scaffolds a new Vite + Svelte 5 project with TypeScript configured and ready to go.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
svelte-bundle create my-app
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Interactive prompts will ask for:
|
|
59
|
+
- **Package manager** — bun, npm, pnpm, or yarn
|
|
60
|
+
- **Optional features** — Tailwind CSS, ESLint, Prettier, Vitest
|
|
61
|
+
- **Git** — initialize a repository
|
|
62
|
+
- **Install** — run the package manager automatically
|
|
63
|
+
|
|
64
|
+
| Flag | Description |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `--template / -t` | Template to use (currently: `default`) |
|
|
67
|
+
| `--pm` | Skip the package manager prompt (`bun`, `npm`, `pnpm`, `yarn`) |
|
|
68
|
+
| `--no-install` | Skip dependency installation |
|
|
69
|
+
| `--no-git` | Skip git initialization |
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
svelte-bundle create my-app --pm bun --no-git
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Project structure
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
my-app/
|
|
79
|
+
├── src/
|
|
80
|
+
│ ├── App.svelte ← root component
|
|
81
|
+
│ ├── main.ts ← entry point
|
|
82
|
+
│ └── lib/
|
|
83
|
+
│ └── index.ts ← library re-export entry
|
|
84
|
+
├── public/
|
|
85
|
+
├── index.html
|
|
86
|
+
├── vite.config.ts
|
|
87
|
+
├── tsconfig.json
|
|
88
|
+
└── package.json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Dev server
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cd my-app
|
|
95
|
+
npm run dev
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## `svelte-bundle build`
|
|
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 |
|
|
115
|
+
|
|
116
|
+
### Default build
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
svelte-bundle build
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Produces a single `dist/index.html` with CSS and JS fully inlined. Open it directly in a browser — no web server required. Drop it into any CMS, email, or embedded environment.
|
|
123
|
+
|
|
124
|
+
### Hydrated build (SSR)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
svelte-bundle build --hydrate
|
|
128
|
+
```
|
|
26
129
|
|
|
27
|
-
|
|
130
|
+
Pre-renders the root component server-side so the page contains real HTML content before JavaScript executes. Useful for:
|
|
28
131
|
|
|
29
|
-
|
|
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
|
|
135
|
+
|
|
136
|
+
The client JS automatically detects whether SSR content is present and calls `hydrate()` or `mount()` accordingly — no separate builds or entry points needed.
|
|
137
|
+
|
|
138
|
+
### How the build pipeline works
|
|
139
|
+
|
|
140
|
+
1. **Client bundle** — `vite build` compiles and minifies the Svelte app via your `vite.config.ts`
|
|
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
|
|
143
|
+
|
|
144
|
+
---
|
|
30
145
|
|
|
31
146
|
## Features
|
|
32
|
-
- [x]
|
|
33
|
-
- [x] Outputs a single `.html` file ready for deployment
|
|
34
|
-
- [x]
|
|
35
|
-
- [x]
|
|
36
|
-
- [x]
|
|
37
|
-
- [x]
|
|
38
|
-
- [x]
|
|
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
|
+
## Requirements
|
|
157
|
+
|
|
158
|
+
- Node.js 18+ or Bun 1.0+
|
|
159
|
+
- Projects created with `svelte-bundle create` include Vite 6 and Svelte 5 as devDependencies
|