vite-svg
vite-svg copied to clipboard
Unnecessary .svg files in build dist
After build all .svg that was imported as component are also present in dist folder. Since svg are in .js they are just waste of space. After deleting them manually of course site works just fine.
I noticed that similar package https://github.com/jpkleemans/vite-svg-loader (without support to SVGO and url svg) does not have this issue (svg files are not present in dist). I messed up in sources of both and in this package (vite-plugin-vue-svg) I can see that it is using transform() hook and vite-svg-loader is using load()
.
So if we just replace transform with load it works for ?component, but not for ?url since no .svg are saved.
U guess it could be fixed like this:
async transform(source, id, isBuild) {
// for ?url svg
},
async load(id) {
// for ?component svg
}
Also enforce: 'pre'
will be required.
Maybe it can be fixed in other way.
What do You @visualfanatic think?