I've added parcel to a create-react-app project that uses the typescript template. I'm trying to add svgs to my outputted js file following the recommendations from their docs. I'm not sure if there's something that has to be done differently in TS, but I set up my project as they suggested as their JSX snippets and it didn't work:
.parcelrc
{
"extends": "@parcel/config-default",
"transformers": {
"jsx:*.svg": ["...", "@parcel/transformer-svg-react"]
}
}
Note: I've added the transformer plugin to my dev deps.
Component.tsx
import BriefcaseSvg from "jsx:../../assets/briefcase.svg";
// ...later in my return statement:
<img src={BriefcaseSvg} alt="work icon" />
// I've also tried
<BriefcaseSvg/>
Every time I get the following error:
Cannot resolve dependency 'jsx:../../assets/briefcase.svg'
I've also tried converting both jsx declarations to tsx.
I've added parcel on top of the standard webpack build tool you get with CRA. Wepback has no problem and displays the icon just find. Parcel also was able to run a build when I didn't include this svg plugin but outputted the svg separately in its own file.
I'd like everything to end up in one js file. How can I achieve this with parcel, react, and TS?