@hyrious/esbuild-plugin-svelte
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

@hyrious/esbuild-plugin-svelte

Minimal efforts to make svelte work in esbuild.

Install

$ npm add -D @hyrious/esbuild-plugin-svelte svelte esbuild

Note: esbuild and svelte are peer dependencies!

Usage

import { build } from 'esbuild'
import { svelte } from '@hyrious/esbuild-plugin-svelte'

build({
  entryPoints: ['main.js'],
  bundle: true,
  plugins: [svelte()],
})

Options

import { typescript } from "@hyrious/esbuild-plugin-svelte";

svelte({
  filter: /\.svelte$/;
  preprocess: typescript();
  emitCss: false;
  compilerOptions: {};
});

filter

The regexp passed to onLoad().

preprocess

If set, it will run svelte.preprocess(source, processors) before svelte.compile().

By default it will enable the typescript() preprocessor which uses esbuild to transform <script lang="ts"> blocks. If you want to totally turn off preprocessing, set this option to false.

emitCss

Whether to emit <style> parts of your svelte components to a .css file. It is implemented by appending an import "path/to/component.svelte.css" statement to the end of the compiled js code.

If you set this to true, it will add these default config to compiler options:

{
  css: "external",
  enableSourcemap: { js: true, css: false },
}

compilerOptions

See svelte.compile.

Credits

Changelog

License

MIT @ hyrious

Readme

Keywords

Package Sidebar

Install

npm i @hyrious/esbuild-plugin-svelte

Weekly Downloads

7

Version

0.2.2

License

MIT

Unpacked Size

51 kB

Total Files

11

Last publish

Collaborators

  • hyrious