Closed adamdehaven closed 1 year ago
Hi, could you share some code of the component where you load your svg file?
Here's an example:
// I can't add `?raw` here since it's a native JS import
import chevronRight from './icn-chevron-right.svg'
It's weird that everything works fine on a dev build, but not production build for certain components
That's strange indeed. Have you tried adding ?raw
? That should also work with native JS imports
When I add ?raw
to the JS imports/exports, I get an error from the build that it can't find the modules, so that's not an option (they come from a separate package)
Does this plugin support vue 2? https://github.com/jpkleemans/vite-svg-loader/issues/10
When I add
?raw
to the JS imports/exports, I get an error from the build that it can't find the modules, so that's not an option (they come from a separate package)
is this still an issue? you can import a file from a separate package if you reference the full name including the node_module namespace e.g. @organization/my-icons/clock.svg?raw
I have a Vue 2 + Vite project utilizing this plugin.
When I run
vite
(oryarn dev
) everything works fine and all svg assets are properly rendered.When I build for production, the assets are instead loaded as a![image](https://user-images.githubusercontent.com/2229946/173711250-3a717833-cfaa-4b88-8d0a-2be0a4e86a9d.png)
url
(I think?) and just the asset path is outputted into the DOMI can't seem to put together a decent reproduction, but I'm happy to provide more info or pair as needed.
Click to expand more info
I also control the repository these icons are sourced from. That repository utilizes webpack and Vue 2, and includes a svg rule in the `chainWebpack` config like this: ```js svgRule.uses.clear() svgRule .oneOf('external') .resourceQuery(/external/) .use('url') .loader('url-loader') .options({ limit: 10000, name: 'img/[name].[hash:7].[ext]' }).end().end() .oneOf('normal') .use('raw') .loader('raw-loader') .end().end() ``` If you look above, this is where the asset URLs (with the hash) are being generated from; however, I can't figure out how to get around this.