mcnamee / react-native-starter-kit

:rocket: A React Native boilerplate app to get you up and running very, very quickly :rocket:
MIT License
3.35k stars 863 forks source link

Image Path #189

Closed DaBlitzStein closed 5 years ago

DaBlitzStein commented 6 years ago

The folder "images" is provided to contain images common on native and react. Webpack files doesn't consider images inside.

Even if I include images inside webpack, the output path is related below "web" and it cannot use common image folder.

Help us reproduce - tell us about your environment

Standar git cloned repository

Steps to reproduce

Try to include an imagen on any file from the directory src/images in the web version.

Expected result

Image appears

Actual result

Image not found.

brainahdev commented 6 years ago

Try this:

npm install url-loader

and in web.pack config (dev and prod) add the following under module->loaders

{ test: /.(png|jpg)$/, loader: 'url-loader' },

Then in your file you can load those images as

img alt="" src={require("../../images/oslogo.png")}

even for me the same issue and resolved like this. It works fine for me.

brainahdev commented 6 years ago

let me know if that works

marktan93 commented 6 years ago

@brainahdev the solution is working. Thanks !