All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- (empty)
- Support for Svelte 5 (Experimental)
4.2.1 2024-01-14
-
@rollup/pluginutils
needs to be a dependency.This should fix #54
4.2.0 2024-01-08
-
SVGs imported as URLs (
import svgUrl from ./some.svg?url
) will now be SVGO optimized before written to disk on production builds.NOTE: SVGs imported as URLs will not be optimized in
dev
mode.This should fix #52
4.1.3 2023-09-01
-
Always return a partial
SourceDescription
when returning codeThis hopefully fixes #48
-
Updated dev dependencies
4.1.2 2023-08-31
-
Return the full JS result from compile
This will include the
map
property as well.This should fix #48.
4.1.1 2023-08-31
-
Set Svelte compiler css option to 'none'
The
css
option to Sveltecompile()
has changed and setting it to aboolean
value has been deprecated.This gave the compilerOptions.css as a boolean is deprecated. Use 'external' instead of false. warning.
Since we're disregarding the
css
field in the generated result, we can set this option tonone
and skip all CSS stuff altogether.
4.1.0 2023-08-07
-
Added the
preCompileHook
option.This is a function that lets the consumer transform the SVG into a Svelte component before being passed to the Svelte compiler.
4.0.1 2023-08-03
Render the contents of the <svg>
tag using {@html}
in the component mode.
This is to prevent Svelte having to parse the entire SVG.
Thanks Arad Alvand for the code.
This solves #39
4.0.0 2023-06-23
Updated dependencies and stuff to play along with Svelte 4
No code changes
3.0.1 2023-05-20
This is a maintenance release with no code changes
- Updated all NPM packages
- Renamed
app.d.ts
tosvg.d.ts
since Svelte doesn't like these typings inapp.d.ts
(see issue 25) - Also copy
svg.d.ts
todist/
on build. - Some fixes to the README file
- Thanks to @joakimnordling for PR #35
3.0.0 2023-03-18
- Support for the SVGO datauri option in the
dataurl
query parameter. This means that?dataurl=base64
,?dataurl=enc
and?dataurl=unenc
works
- Upgraded all NPM packages and bumped the SVGO dependency ro SVGO >=3.0
2.1.2 2023-01-29
-
Keep the generated source map
This removes the "Sourcemap is likely to be incorrect: a plugi (sveltekit-svg) was used to transform files..." warning seen when using this plugin outside of SvelteKit
2.1.1 2023-01-25
-
Hot-reload is working for component instances, that is editing a SVG imported as a component will hot-reload it. SVG:s imported a URL:s will require a page reload.
This solves issue #30
2.0.2 2022-12-29
-
Proper type in sample
.d.ts
for component. This will get proper intellisense for all valid SVG attributes. Thank to YummYume for the example code. -
Upgraded all NPM packages
2.0.0 2022-12-12
- Updated to work with Vite 4.0 and latest SvelteKit
1.1.0 2022-11-17
-
We now support generating inline data URLs (
data:image/svg+xml;base64,...
), which can be used in<img src>
attributes, by appending the querystring variable?dataurl
to an SVG import.<script> import icon1 from `$assets/icon1.svg?dataurl` </script> <img src={icon1} />
?dataurl
differs from?url
in that SVGO optimization/transform will be applied to the SVG before it's turned into a data URL.
1.0.1 2022-11-07
-
Use the proper Vite
Plugin
type. The transform signature wasn't 100% compatible with thePlugin
interface and would cause errors when the Vite config file is a Typescript file (e.g.vite.config.ts
) -
The suggested
*.svg?component
type definition now has a proper Svelte typed component interfacedeclare module '*.svg?component' { const content: ConstructorOfATypedSvelteComponent export default content }
Lets go 1.0
- Use
vite.config.js
instead ofsvelte.config.js
in README. Thank you Arad for the PR
- Type definitions for the update Svgo dependency are stricter. If we get an
OptimizeError
from SVGO we notify and return early
No changes. Updated package dependencies and added to the README file.
Thanks to Miguel Camba for the contribution.
- By giving
false
as value to the SVGO option you can bypass SVGO altogether. This is useful when optimization might break SVG animations and alike.
Thanks to Jani for the contributions
-
It's now possible to pass multiple
svg
transformers based on path prefixes if you want to apply different SVGO options for SVGs in different locations.Example:
const config = { ..., kit: { ..., vite: { plugins: [ svg({ includePaths: ["./src/lib/icons/", "./src/assets/icons/"], svgoOptions: { multipass: true, plugins: [ "preset-default", { name: "removeAttrs", params: { attrs: "(fill|stroke)" } } ], }, }), svg({ includePaths: ["./src/lib/graphics/"], svgoOptions: { multipass: true, plugins: ["preset-default" ], }, }), ] } } }
includePaths
will be normalized, so they can be both absolute and relative (to the current working directory).
- Passing
path
property to SVGO by default
- Updated README to reflect reality. Mainly use ESM in example
- Update
transform
params for Vite 2.7.0. This is just an internal change. Thank you James Camilleri for the fix.
- Noticed that the
index.d.ts
file was missing from the package. So no code changes
-
It is now possible to pass attributes to the SVG when it is imported as a Svelte component
<script> import Icon from './icon.svelte' </script> <Icon width="200" />
Thanks to @AradAral for pushing on this issue
- No code changes, upgraded package dependencies
- No changes, just a version bump to sync the CHANGELOG file
-
svgo.optimize()
expects the options argument to be an object ornull
. However, the TS typings says object orundefined
, which previously seem to have been fine but no longer is.This solves bug report #8
- The Svelte component wasn't using the optimized SVG output. Thanks @bummzack (https://github.com/bummzack) for the PR.
- Updated README to reflect that the
plugins
property should be a member of thevite
property
- Fixed a typo in the README
- Corrected the years in this file
- Changed Svelte peer dep to 3.x
- Added changelog
- Bump version to 0.1.0