@svelte-put/inline-svg
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

@svelte-put/inline-svg

npm.badge bundlephobia.badge docs.badge

Svelte action use:inlineSvg for inlining dynamic SVGs (fetched from network)

svelte-put

This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.

Usage & Documentation

See the dedicated documentation page here.

Dynamic SVGs - Svelte Action

<script>
  import { inlineSvg } from '@svelte-put/inline-svg';
</script>

<svg use:inlineSvg={'https://example.com/icon.svg'}></svg>

Static SVGs - Vite Plugin / Svelte Preprocessor

Vite Plugin

To inline static SVGs during build time, use the exported Vite plugin:

// vite.config.js
import path from 'path';
import { inlineSvg } from '@svelte-put/inline-svg/vite';

/** @type {import('vite').UserConfig} */
const config = {
  plugins: [
    inlineSvg(),
    sveltekit(),
  ],
};
export default config;

Bare Preprocessor

The Svelte preprocessor is what is used internally by the aforementioned Vite plugin, which is the recommended. However, if your setup requires using the preprocessor directly, you can do so:

// svelte.config.js
import { inlineSvg } from '@svelte-put/inline-svg/preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: [inlineSvg()],
};
export default config;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.0.0
48latest
4.0.0-next.5
0next

Version History

VersionDownloads (Last 7 Days)Published
4.0.0
48
4.0.0-next.5
0
4.0.0-next.4
0
4.0.0-next.3
0
4.0.0-next.21
4.0.0-next.10
4.0.0-next.00
3.0.155
3.0.02
2.0.024
1.0.00

Package Sidebar

Install

npm i @svelte-put/inline-svg

Weekly Downloads

89

Version

4.0.0

License

MIT

Unpacked Size

32.1 kB

Total Files

15

Last publish

Collaborators

  • vnphanquang