4.0.1 • Published 5 months ago
@svelte-put/inline-svg v4.0.1
@svelte-put/inline-svg
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;
Changelog
4.0.1
5 months ago
4.0.0
8 months ago
4.0.0-next.5
8 months ago
4.0.0-next.4
9 months ago
4.0.0-next.1
1 year ago
4.0.0-next.0
1 year ago
4.0.0-next.3
10 months ago
4.0.0-next.2
1 year ago
3.0.1
1 year ago
3.0.0
2 years ago
2.0.0
2 years ago
1.0.0
2 years ago