Plugin to compile svelte components for bundling with esbuild.
Install both this plugin and esbuild (esbuild must be above 0.8.1).
A simple build script looks like
const esbuild = require('esbuild');
const sveltePlugin = require('esbuild-svelte');
esbuild.build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
plugins: [sveltePlugin()],
logLevel: 'info',
}).catch(() => process.exit(1))
The example
folder of this repository is a great starting off point for a "complete" project.
By default, esbuild-svelte
emits external css files from Svelte for esbuild
to process. If this isn't desired, use a configuration that turns off external css output and instead includes it in the javascript output. For example: sveltePlugin({compileOptions: {css: true}})
You can see the full API here, which also includes support for Svelte's compiler options and preprocessing API.
Clone, npm install
, npm link
and it's good to go! Releases are automated (with the right permissions), just by running npm version patch|minor|major
.