oliverfindl / vue-svg-inline-plugin Goto Github PK
View Code? Open in Web Editor NEWVue plugin for inline replacement of SVG images with actual content of SVG files.
License: MIT License
Vue plugin for inline replacement of SVG images with actual content of SVG files.
License: MIT License
I'm not an expert, I'm sorry if I'm wrong with my assumptions. Vue instance is injected in install method and Axios instance is passed in options object or taken from global scope. Would setting Vue and Axios as peerDependencies help reduce the size of the bundle?
Warning:
Should not import the named export 'name' (imported as 'name') from default-exporting module (only default export is available soon)
Hi there,
My application which uses vue-svg-inline-plugin
is being served via an iframe. Unfortunately, this crashes the app when the user's browser is running in incognito/private mode.
Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
at Object.install (webpack-internal:///./node_modules/vue-svg-inline-plugin/src/index.js:222:71)
at Object.use (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:3957:28)
[...]
Unfortunately, setting cache.persistent
to false does not help. Is there another way to completely disable the use of localstorage?
Hi, thanks for this plugin.
On nuxt 3, I setup the loader as a plugin this way in the nuxt plugins folder:
import VueSvgInlinePlugin from "vue-svg-inline-plugin"
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueSvgInlinePlugin)
})
But I get this error in my console:
(node:13568) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Thanks for this plugin.
I was wondering how we could make it work with variable paths?
I made an Icon
component like this:
<img
v-svg-inline
:src="`/@/assets/icons/${style}/${icon}.svg`"
class="svg-icon"
/>
It works while in development (yarn dev
) but once building for production it fails.
There is an error in the console:
[vue-svg-inline-plugin] TypeError: [vue-svg-inline-plugin] Argument property is not valid! [file.content="<!DOCTYPE html>
.. content of my index.html
Can this be done? If not, what approach would you recommend instead?
Cheers
It looks that the plugin caches the SVG file before importing. So if the file is changed, I still see old file inline. As a workaround I had to add "?.." in the URL.
So does the cache really exist? And how to flush it on source image change?
During the migration of my Vue 3 app from Webpack to Vite, I decided to switch from https://github.com/oliverfindl/vue-svg-inline-loader to this plugin, as it was recommended in README. Unfortunately, I had to rename all directive usages from svg-inline
to v-svg-inline
, because the custom directive simply doesn't work.
Reproduction link: https://codesandbox.io/s/relaxed-mendel-98zk3y
Am I missing something or this is a bug?
Hi, everything was working as expected until I built the project to host it in netlify.
Once it was uploaded, the svgs stopped working inline and instead they were loaded through data/image base64.
Any way to configure this the right way? I'm using Nuxt, Vite and Tailwind JIT.
It would be nice to have a changelog of what's changing in each version.
Potentially even autogenerated changelogs based off commit messages?
On my vue2 projects, I used https://github.com/oliverfindl/vue-svg-inline-loader that performed the inlining at build time and thus reducing the amount of HTTP request when visiting the page.
Is there a way to setup this plugin to perform the inlining at build time?
Hi, is there a plan to add type declaration files for this project?
This allows for full compatibility with typescript projects.
Hi, this is more of a question than an "issue".
First of all thank you for your work on both this and on vue-svg-inline-loader
.
I found a thread on vue-svg-inline-loader
that mentioned that this new plugin supports the first dynamic value in the :src
attribute, but I don't see any examples of how that should work.
I am trying to use it but it doesn't work, so I assume I am doing something wrong so an example of what you meant would be great.
e.g. from what you wrote I would expect something like: <img v-svg-inline :src="`./assets/icons/${icon}.svg`" />
to work, but I've probably misunderstood what you meant.
Thanks in advance!
Hey there, first of all, thank you very much for this plugin! Currently, I believe it's the only one for vue3, which is great. But what's really a pain is that I can't use the sprite mode. The reason I want to use it is since every icon ever needed will make a http request to it. So it's not cached or anything, which leads in thousands of HTTP requests for a relatively simple list of cards.
To avoid this, I wanted to use the sprite mode with <img v-svg-inline.sprite ...
. But then, the viewBox attribute is not applied to the tag where the icon is finally used. This results in unusable behaviour, since a viewBox attribute is absolutely needed on both sites (both on in sprite & on in the UI). It leads to icons not properly resizing.
Is there a way you could fix this? Or is there a reason why viewBox is not getting applied to the in UI?
it drops event handlers right now, for instance, @click="onClick" not triggering
We noticed some random JS exceptions in Sentry logs which made us a bit confused.
For example:
TypeError: [vue-svg-inline-plugin] Argument is not valid! [path="/image/i.702/w.400:h.400:f.0/image.png"]
The confusion is because this element does not contain SVG and should not be affected at all:
<img v-lazy="getImageUrl(item.image_id)">
The same Vue component contains other elements using vue-svg-inline-plugin, for example:
<img v-svg-inline src="/customer/images/challenge-success.svg" alt="">
<img v-svg-inline src="/customer/images/challenge-failed.svg" alt="">
Any ideas?
@oliverfindl Hi Oliver, may I know where should I place the Webpack configuration in, if i am building a vue2 with quasar project? should I create a new boot file and name it as any name?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.