Repository navigation
Svelte 5 Plugin for Build Awesome (11ty) v1.0.1
·
5 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
An official Svelte plugin for Build Awesome and Eleventy to process .svelte files as templates and output server-rendered components that ship no client-side JavaScript.
Usage
npm install @11ty/eleventy-plugin-svelteAdd it to your configuration file (usually eleventy.config.js):
import sveltePlugin from "@11ty/eleventy-plugin-svelte";
export default function($config) {
$config.addPlugin(sveltePlugin);
}Output component CSS and <svelte:head> content in your layout:
<head>
{% getBundle "head" %}
<style>{% getBundle "css" %}</style>
</head>Requirements
- Eleventy 3.0.0+ or Build Awesome 4.0.0+
- Svelte 5
- Node.js 22 or newer
Features
- Builds
*.sveltefiles in the input directory as pages. Files in theincludesdirectory can be imported but don't write any output. - Each component's
<style>blocks, including those of components it imports, are added to the page'scssbundle. <svelte:head>content is added to the page'sheadbundle.export const datain<script module>(an object or a function) feeds into the data cascade.- The page's data cascade is passed to the page component as props.
- Every component can read
page,dataandfunctions(JavaScript template functions, universal filters and shortcodes) throughgetContext. - Top-level
awaitworks in components, using Svelte's async SSR. - Supports
.svelte.jsand.svelte.tsmodules (runes outside components). .sveltefiles work as layouts: render the child template with{@html content}, and can chain to another layout withlayoutviadata.- Compiled components are cached on disk. A later build skips compiling when no component, imported module, plugin option or Svelte version has changed.
- Plugin options for:
cacheDirectory,input,cssBundleName,headBundleName,cssBundleBucket,compilerOptions,preprocess,configureContextandrollupOptions.
Limitations
- No client-side hydration yet.
- Svelte's hydration comment markers stay in the output until Svelte adds an official API to strip them.
Full Changelog: svelte-1.0.0...svelte-1.0.1