nirsky / figma-plugin-react-template

Quickstart your Figma Plugin with this template and tooling.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Images not loading from assets folder

edu81 opened this issue · comments

commented

I am trying to use an image from assets folder like:

<img src={require('../assets/logo.svg')} alt="NONE"/>

The plugin UI is always displaying "NONE".

App.tsx is located in "components" folder while images are in "assets" folder, both folders on same level.

Any help here?

By writing it as require('../assets/logo.svg').default, it worked.

add file ./src/types.d.ts

declare module '*.svg' {
	const content: any;
	export default content;
}

then import logo src like this

import logo from './logo.svg';
<img src={logo} />

https://stackoverflow.com/a/45887328/5648839

Added built in SVG TS support
#34