I have the folder structure like the following.
src/
components/
Icon/
Icon.js
Style.js
images/
apple.svg
google.svg
facebook.svg
index.js
I want to export the paths of images under images folder in 'images/index.js'.
I tried something like this below.
images/index.js
export const apple = './apple.svg';
export { google } from './google.svg';
export const facebook = './facebook.svg';
And I want to load the paths of those images in '/Components/Icon/Style.js' like the following.
Style.js
import styled from 'styled-components';
// I know this works fine
import apple from '../../images/apple.svg';
// This doesn't work although I want it to work.
import { google } from '../../images/index';
// This doesn't work as well although I want it to work.
import { facebook } from '../../images/index';
const Icon = styled.i`
background: blah blah blah
`;
export default Icon;
However, I couldn't load the paths of images.
What is the right way to do that?
Is it impossible?
export const apple = './apple.svg';
Is this the only way I can load the path of image?