posthtml-svelte
Write Svelte in your HTML.
This PostHTML plugin is a proof-of-concept that compiles Svelte written within an HTML file.
Increment the count: {count}
Steps
-
Use PostHTML to extract Svelte code inside of a non-standard
svelte
tag -
Use the Svelte compiler to generate static markup and styles
-
Use Rollup to generate the JavaScript bundle that hydrates the HTML
-
Use PostHTML to inject the static markup and bundle into the HTML
Example
Before
After
Install
yarn add -D posthtml-svelte# OR npm i -D posthtml-svelte
Usage
Single file
By default, the bundled JavaScript is injected into the HTML. This is not ideal for caching.
const fs = ;const posthtml = ;const svelte = ; async { const html = fs; const result = await ; fs;};