jaredLunde / snowpack-plugin-svgr

Use svgr to transform your SVGs into React components with Snowpack
MIT License
18 stars 4 forks source link

SVGs ignored by plugin will not be handled by snowpack default assets plugin #1

Closed PeterPanZH closed 3 years ago

PeterPanZH commented 4 years ago

Consider we have flowing projext:

|-dir1
|--foo.svg
|-dir2
|--bar.svg

and we have this configration of snowpack:

// snowpack.config.json
{
  "plugins": [
    "snowpack-plugin-svgr",
    {"include": ["dir1/**/*.svg"]}
}

now in application code:

import FooIcon from 'dir1/foo.svg';
import bar from 'dir2/bar.svg';

bar is expected to be the url of dir2/bar.svg but we get a 404 error because bar.svg.proxy.js was not generated.

https://github.com/jaredLunde/snowpack-plugin-svgr/blob/master/src/index.ts#L41 here return null will cause snowpack ignore the svg file.

jaredLunde commented 4 years ago

Do you have a solution?

PeterPanZH commented 4 years ago

https://github.com/pikapkg/snowpack/blob/master/snowpack/src/build/build-import-proxy.ts#L175 just copy this...

But I think snowpack should provide a interface to solve this problem.

jaredLunde commented 4 years ago

Thanks for digging that up. I think I have an idea here that I'll try today.

mhsattarian commented 3 years ago

Hey @jaredLunde, any update on this?

this issue also affects importing SVGs in CSS and css-in-js, for example:

image

SVG background file can't be accessed.

jaredLunde commented 3 years ago

@mhsattarian not really my problem. Put in a PR if you figure it out.

fgblomqvist commented 3 years ago

Why was this closed? It's still an issue, no matter whether you want to deal with it or not. It's fine if you don't have time, but don't close it since that means that it's no longer an issue...someone might come along eventually and help fix it.

jaredLunde commented 3 years ago

Cool

fgblomqvist commented 3 years ago

Your attitude is just terrible man, thank god the open source community is generally the opposite of you. Time to switch dependency, this one clearly has no future. Please scope your future npm packages under @douchebag/ to prevent cluttering the shared space.

jaredLunde commented 3 years ago

Thanks for the feedback! Happy trails.