JavaScript for WordPress Forums Gutenberg Development Plugin path in index.js file Reply To: Plugin path in index.js file

#60686
Zac Gordon
Keymaster

Great question.

To give some context to how things are done in the React world of WordPress going forward, you would want to import your SVG images directly into your JS code (like we do with the SVG icons in the examples).

This article goes into more depth on the topic: https://medium.com/@kossnocorp/solving-the-unsolvable-svg-icons-with-react-preact-webpack-4185032f2601

But the short answer is, that is not the way you want to approach this problem. You want to add the SVG file to your plugin folder architecture then import the SVG file using a relative file path and JavaScript imports. This will also require an appropriate webpack loader for SVG files.

Hope that helps you get moving in the right direction!